Commit fcb517f9 authored by hasan khaddour's avatar hasan khaddour

add project types and completion entities

parent cd02d535
......@@ -10,7 +10,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System ;
namespace PSManagement.Application.Employees.UseCases.Queries.GetEmployeeTrackHistory
{
public class GetEmployeeTrackHistoryQueryHandler : IQueryHandler<GetEmployeeTrackHistoryQuery, Result<IEnumerable<EmployeeTrackDTO>>>
......
......@@ -7,7 +7,7 @@
<ItemGroup>
<Folder Include="Behaviors\AuthorizationBehavior\" />
<Folder Include="Projects\UseCases\Commands\ChangeParticipantPartialTime\" />
<Folder Include="Projects\UseCases\Commands\ChangeParticiptionInfo\" />
<Folder Include="Tracks\UseCaes\Queries\GetUncompletedTracks\" />
</ItemGroup>
......
......@@ -8,4 +8,5 @@
public string AttachmentName { get; set; }
public string AttachmentDescription { get; set; }
}
}
\ No newline at end of file
using System;
namespace PSManagement.Application.Projects.Common
{
public class ProjectCompletionDTO
{
public int Id { get; set; }
public int ProjectId { get; set; }
public ProjectDTO Project { get; set; }
public DateTime CompletionDate { get; set; }
public String CustomerNotes { get; set; }
public int CustomerRate { get; set; }
}
}
\ No newline at end of file
using PSManagement.Application.Employees.Common;
using PSManagement.Application.FinancialSpends.Common;
using PSManagement.Application.ProjectsTypes.Common;
using PSManagement.Domain.Customers.Entities;
using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.Projects.Entities;
......@@ -15,6 +16,7 @@ namespace PSManagement.Application.Projects.Common
public ProposalInfo ProposalInfo { get; set; }
public ProjectClassification ProjectClassification { get; set; }
public ProjectInfo ProjectInfo { get; set; }
public ProjectTypeDTO ProjectType { get; set; }
public string CurrentState { get; set; }
public Aggreement ProjectAggreement { get; set; }
public int TeamLeaderId { get; set; }
......
using Ardalis.Result;
using PSManagement.SharedKernel.CQRS.Command;
using System;
namespace PSManagement.Application.Projects.UseCases.Commands.CompleteProgressProject
{
public record CompleteProgressProjectCommand(
int ProjectId
public record CompleteProjectCommand(
int ProjectId,
DateTime CompletionDate,
String CustomerNotes,
int CustomerRate
) : ICommand<Result>;
}
using Ardalis.Result;
using AutoMapper;
using PSManagement.Domain.Projects.DomainErrors;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.Repositories;
......@@ -9,23 +10,23 @@ using System.Threading.Tasks;
namespace PSManagement.Application.Projects.UseCases.Commands.CompleteProgressProject
{
public class CompleteProgressProjectCommandHandler : ICommandHandler<CompleteProgressProjectCommand, Result>
public class CompleteProjectCommandHandler : ICommandHandler<CompleteProjectCommand, Result>
{
private readonly IProjectsRepository _projectsRepository;
private readonly IUnitOfWork _unitOfWork;
public CompleteProgressProjectCommandHandler(
private IMapper _mapper;
public CompleteProjectCommandHandler(
IProjectsRepository projectsRepository,
IUnitOfWork unitOfWork
)
IUnitOfWork unitOfWork,
IMapper mapper)
{
_projectsRepository = projectsRepository;
_unitOfWork = unitOfWork;
_mapper = mapper;
}
public async Task<Result> Handle(CompleteProgressProjectCommand request, CancellationToken cancellationToken)
public async Task<Result> Handle(CompleteProjectCommand request, CancellationToken cancellationToken)
{
Project project = await _projectsRepository.GetByIdAsync(request.ProjectId);
if (project is null)
......@@ -34,7 +35,7 @@ namespace PSManagement.Application.Projects.UseCases.Commands.CompleteProgressPr
}
else{
Result result = project.Complete();
Result result = project.Complete(_mapper.Map<ProjectCompletion>(request));
await _unitOfWork.SaveChangesAsync();
return result;
}
......
namespace PSManagement.Application.ProjectsTypes.Common
{
public class ProjectTypeDTO
{
public int Id { get; set; }
public string TypeName { get; set; }
public string Description { get; set; }
public int ExpectedEffort { get; set; }
}
}
\ No newline at end of file
using Ardalis.Result;
using PSManagement.SharedKernel.CQRS.Command;
using PSManagement.SharedKernel.CQRS.Query;
namespace PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType
{
public record CreateNewTypeCommand(
string TypeName,
string Description,
int ExpectedEffort
) : ILoggableCommand<Result<int>>;
}
using Ardalis.Result;
using AutoMapper;
using PSManagement.Domain.Projects.DomainErrors;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.Repositories;
using PSManagement.SharedKernel.CQRS.Command;
using System.Threading;
using System.Threading.Tasks;
namespace PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType
{
public class CreateNewTypeCommandHandler : ICommandHandler<CreateNewTypeCommand, Result<int>>
{
private readonly IProjectTypesRepository _projectTypesRepository;
private readonly IMapper _mapper;
public CreateNewTypeCommandHandler(
IMapper mapper,
IProjectTypesRepository projectTypesRepository)
{
_projectTypesRepository = projectTypesRepository;
_mapper = mapper;
}
public async Task<Result<int>> Handle(CreateNewTypeCommand request, CancellationToken cancellationToken)
{
var result = await _projectTypesRepository.GetByTypeName(request.TypeName);
if (result is not null)
{
return Result.Invalid(PrjectTypesErrors.InvalidName);
}
var projectType = await _projectTypesRepository.AddAsync(_mapper.Map<ProjectType>(request));
return Result.Success(projectType.Id);
}
}
}
using Ardalis.Result;
using PSManagement.SharedKernel.CQRS.Command;
namespace PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType
{
public record RemoveTypeCommand(
int typeId
) : ILoggableCommand<Result>;
}
using Ardalis.Result;
using AutoMapper;
using PSManagement.Domain.Projects;
using PSManagement.Domain.Projects.DomainErrors;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.Repositories;
using PSManagement.SharedKernel.CQRS.Command;
using PSManagement.SharedKernel.Specification;
using System.Threading;
using System.Threading.Tasks;
namespace PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType
{
public class RemoveTypeCommandHandler : ICommandHandler<RemoveTypeCommand, Result>
{
private readonly IProjectTypesRepository _projectTypesRepository;
private readonly IMapper _mapper;
private readonly BaseSpecification<ProjectType> _specification;
public RemoveTypeCommandHandler(
IMapper mapper,
IProjectTypesRepository projectTypesRepository)
{
_projectTypesRepository = projectTypesRepository;
_mapper = mapper;
_specification = new ProjectTypeSpecification();
}
public async Task<Result> Handle(RemoveTypeCommand request, CancellationToken cancellationToken)
{
var result = await _projectTypesRepository.GetByIdAsync(request.typeId ,_specification);
if (result is null)
{
return Result.Invalid(PrjectTypesErrors.InvalidEntryError);
}
if (result.Projects is not null )
{
return Result.Invalid(PrjectTypesErrors.InvalidEntryError);
}
await _projectTypesRepository.DeleteAsync(result);
return Result.Success();
}
}
}
using Ardalis.Result;
using PSManagement.SharedKernel.CQRS.Command;
namespace PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType
{
public record UpdateTypeCommand(
int Id,
string TypeName,
string Description,
int ExpectedEffort
) : ILoggableCommand<Result>;
}
using Ardalis.Result;
using AutoMapper;
using PSManagement.Domain.Projects.DomainErrors;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.Repositories;
using PSManagement.SharedKernel.CQRS.Command;
using System.Threading;
using System.Threading.Tasks;
namespace PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType
{
public class UpdateTypeCommandHandler : ICommandHandler<UpdateTypeCommand, Result>
{
private readonly IProjectTypesRepository _projectTypesRepository;
private readonly IMapper _mapper;
public UpdateTypeCommandHandler(
IMapper mapper,
IProjectTypesRepository projectTypesRepository)
{
_projectTypesRepository = projectTypesRepository;
_mapper = mapper;
}
public async Task<Result> Handle(UpdateTypeCommand request, CancellationToken cancellationToken)
{
var result = await _projectTypesRepository.GetByTypeName(request.TypeName);
if (result is not null)
{
return Result.Invalid(PrjectTypesErrors.InvalidEntryError);
}
var projectType = await _projectTypesRepository.UpdateAsync(_mapper.Map<ProjectType>(request));
return Result.Success();
}
}
}
using Ardalis.Result;
using PSManagement.Application.ProjectsTypes.Common;
using PSManagement.SharedKernel.CQRS.Query;
using PSManagement.SharedKernel.Specification;
using System.Collections.Generic;
namespace PSManagement.Application.ProjectsTypes.UseCases.Queries.GetProjectsTypes
{
public record GetProjectsTypesQuery(
) : IQuery<Result<IEnumerable<ProjectTypeDTO>>>;
}
using Ardalis.Result;
using AutoMapper;
using PSManagement.Application.ProjectsTypes.Common;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.Repositories;
using PSManagement.SharedKernel.CQRS.Query;
using PSManagement.SharedKernel.Specification;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace PSManagement.Application.ProjectsTypes.UseCases.Queries.GetProjectsTypes
{
public class GetProjectsTypesQueryHandler : IQueryHandler<GetProjectsTypesQuery, Result<IEnumerable<ProjectTypeDTO>>>
{
private readonly IProjectTypesRepository _projectTypesRepository;
private readonly IMapper _mapper;
private readonly BaseSpecification<ProjectType> _specification;
public GetProjectsTypesQueryHandler(
IMapper mapper,
IProjectTypesRepository projectTypesRepository)
{
_projectTypesRepository = projectTypesRepository;
_mapper = mapper;
}
public async Task<Result<IEnumerable<ProjectTypeDTO>>> Handle(GetProjectsTypesQuery request, CancellationToken cancellationToken)
{
var result = await _projectTypesRepository.ListAsync();
if (result is null)
{
result = new List<ProjectType>();
}
return Result.Success(_mapper.Map<Result<IEnumerable<ProjectTypeDTO>>>(result)); ;
}
}
}
using Ardalis.Result;
using PSManagement.Application.ProjectsTypes.Common;
using PSManagement.SharedKernel.CQRS.Query;
namespace PSManagement.Application.ProjectsTypes.UseCases.Queries.GetTypeById
{
public record GetTypeByIdQuery(
int TypeId
) : IQuery<Result<ProjectTypeDTO>>;
}
using Ardalis.Result;
using AutoMapper;
using PSManagement.Application.ProjectsTypes.Common;
using PSManagement.Application.ProjectsTypes.UseCases.Queries.GetProjectsTypes;
using PSManagement.Domain.Projects.DomainErrors;
using PSManagement.Domain.Projects.Repositories;
using PSManagement.SharedKernel.CQRS.Query;
using System.Threading;
using System.Threading.Tasks;
namespace PSManagement.Application.ProjectsTypes.UseCases.Queries.GetTypeById
{
public class GetTypeByIdQueryHandler : IQueryHandler<GetTypeByIdQuery, Result<ProjectTypeDTO>>
{
private readonly IProjectTypesRepository _projectTypesRepository;
private readonly IMapper _mapper;
public GetTypeByIdQueryHandler(
IMapper mapper,
IProjectTypesRepository projectTypesRepository)
{
_projectTypesRepository = projectTypesRepository;
_mapper = mapper;
}
public async Task<Result<ProjectTypeDTO>> Handle(GetProjectsTypesQuery request, CancellationToken cancellationToken)
{
var result = await _projectTypesRepository.ListAsync();
if (result is null)
{
return Result.Invalid(PrjectTypesErrors.InvalidEntryError);
}
return Result.Success(_mapper.Map<Result<ProjectTypeDTO>>(result)); ;
}
}
}
using PSManagement.Domain.Tracking.ValueObjects;
using PSManagement.Domain.Employees.Entities;
using PSManagement.Application.Employees.Common;
namespace PSManagement.Application.Tracks.Common
{
public class EmployeeTrackDTO
{
public int Id { get; set; }
public int EmloyeeId { get; set; }
public Employee Emloyee { get; set; }
public EmployeeDTO Employee { get; set; }
public int TrackId { get; set; }
public TrackInfo TrackInfo { get; set; }
public EmployeeWorkInfo EmployeeWorkInfo { get; set; }
......
using PSManagement.Domain.Tracking.ValueObjects;
using System;
namespace PSManagement.Contracts.Projects.Response
{
public class StepTrackResponse
{
public int StepId { get; set; }
public int TrackId { get; set; }
public String ExecutionState { get; set; }
public TrackInfo TrackInfo { get; set; }
public int ExecutionRatio { get; set; }
}
}
\ No newline at end of file
using PSManagement.Domain.Tracking.ValueObjects;
using PSManagement.Domain.Employees.Entities;
using PSManagement.Contracts.Projects.Response;
namespace PSManagement.Contracts.Tracks.Response
{
public record EmployeeTrackResponse(
int EmloyeeId,
int TrackId,
Employee Employee,
EmployeeResponse Employee,
TrackInfo TrackInfo,
EmployeeWorkInfo EmployeeWorkInfo,
EmployeeWork EmployeeWork,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment