Commit eb28e1fd authored by hasan khaddour's avatar hasan khaddour

fix issues

parent 92f7ddf3
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Middleware\ExceptionHandling\" /> <Folder Include="Middleware\ExceptionHandler\" />
</ItemGroup> </ItemGroup>
</Project> </Project>
...@@ -25,6 +25,7 @@ namespace PSManagement.Application.DI ...@@ -25,6 +25,7 @@ namespace PSManagement.Application.DI
return services; return services;
} }
#region Mediator
private static IServiceCollection AddMyMediatR(this IServiceCollection services) { private static IServiceCollection AddMyMediatR(this IServiceCollection services) {
services.AddMediatR(typeof(DependencyInjection).Assembly); services.AddMediatR(typeof(DependencyInjection).Assembly);
...@@ -35,7 +36,10 @@ namespace PSManagement.Application.DI ...@@ -35,7 +36,10 @@ namespace PSManagement.Application.DI
return services; return services;
} }
#endregion Mediator
#region Mappers
private static IServiceCollection AddMappers(this IServiceCollection services) private static IServiceCollection AddMappers(this IServiceCollection services)
{ {
...@@ -50,6 +54,7 @@ namespace PSManagement.Application.DI ...@@ -50,6 +54,7 @@ namespace PSManagement.Application.DI
return services; return services;
} }
#endregion Mappers
} }
} }
......
...@@ -3,8 +3,6 @@ using PSManagement.Application.Contracts.Authentication; ...@@ -3,8 +3,6 @@ using PSManagement.Application.Contracts.Authentication;
using PSManagement.Application.Customers.Common; using PSManagement.Application.Customers.Common;
using PSManagement.Application.Employees.Common; using PSManagement.Application.Employees.Common;
using PSManagement.Application.Projects.Common; using PSManagement.Application.Projects.Common;
using PSManagement.Application.Projects.UseCases.Commands.CompleteProgressProject;
using PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType;
using PSManagement.Application.Tracks.Common; using PSManagement.Application.Tracks.Common;
using PSManagement.Application.ProjectsTypes.Common; using PSManagement.Application.ProjectsTypes.Common;
...@@ -16,7 +14,6 @@ using PSManagement.Domain.Customers.ValueObjects; ...@@ -16,7 +14,6 @@ using PSManagement.Domain.Customers.ValueObjects;
using PSManagement.Domain.Employees.Entities; using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.Identity.Entities; using PSManagement.Domain.Identity.Entities;
using PSManagement.Domain.Projects.Entities; using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.ValueObjects;
using PSManagement.Domain.Tracking; using PSManagement.Domain.Tracking;
using PSManagement.Domain.Tracking.Entities; using PSManagement.Domain.Tracking.Entities;
using System; using System;
...@@ -69,33 +66,4 @@ namespace PSManagement.Application.Mappers ...@@ -69,33 +66,4 @@ namespace PSManagement.Application.Mappers
} }
} }
public class ProjectDTOMapperConfiguration : Profile {
public ProjectDTOMapperConfiguration()
{
CreateMap<Project, ProjectDTO>().ReverseMap();
CreateMap<Project, ProjectDetailsDTO>().ReverseMap();
CreateMap<ProjectType, ProjectTypeDTO>().ReverseMap();
CreateMap<Project, ProjectInfo>()
.ConvertUsing(project => project.ProjectInfo);
CreateMap<EmployeeParticipate, EmployeeParticipateDTO>()
.ForMember(d => d.ProjectInfo, opt => opt.MapFrom(s => s.Project.ProjectInfo))
.ForMember(d => d.Employee, op => op.MapFrom(e => e.Employee))
;
CreateMap<CreateNewTypeCommand, ProjectType>();
CreateMap<UpdateTypeCommand, ProjectType>();
CreateMap<ParticipationChange, ParticipationChangeDTO>().ReverseMap();
CreateMap <CompleteProjectCommand, ProjectCompletion>();
}
}
} }
using AutoMapper;
using PSManagement.Application.Projects.Common;
using PSManagement.Application.Projects.UseCases.Commands.CompleteProgressProject;
using PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType;
using PSManagement.Application.ProjectsTypes.Common;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.ValueObjects;
using PSManagement.Domain.ProjectsTypes.Entites;
namespace PSManagement.Application.Mappers
{
public class ProjectDTOMapperConfiguration : Profile {
public ProjectDTOMapperConfiguration()
{
CreateMap<Project, ProjectDTO>().ReverseMap();
CreateMap<Project, ProjectDetailsDTO>().ReverseMap();
CreateMap<ProjectType, ProjectTypeDTO>().ReverseMap();
CreateMap<Project, ProjectInfo>()
.ConvertUsing(project => project.ProjectInfo);
CreateMap<EmployeeParticipate, EmployeeParticipateDTO>()
.ForMember(d => d.ProjectInfo, opt => opt.MapFrom(s => s.Project.ProjectInfo))
.ForMember(d => d.Employee, op => op.MapFrom(e => e.Employee))
;
CreateMap<CreateNewTypeCommand, ProjectType>();
CreateMap<UpdateTypeCommand, ProjectType>();
CreateMap<ParticipationChange, ParticipationChangeDTO>().ReverseMap();
CreateMap <CompleteProjectCommand, ProjectCompletion>();
}
}
}
using FluentValidation;
using PSManagement.Application.Projects.UseCases.Commands.ChangeProjectManager;
namespace PSManagement.Application.Projects.UseCases.Commands.ChangeEmployeeParticipation
{
public class ChangeEmployeeParticipationCommandValidator : AbstractValidator<ChangeEmployeeParticipationCommand>
{
public ChangeEmployeeParticipationCommandValidator()
{
RuleFor(patrticipation => patrticipation.PartialTimeRation)
.GreaterThan(0);
RuleFor(patrticipation => patrticipation.Role)
.NotEmpty()
.MinimumLength(5);
}
}
}
...@@ -6,7 +6,7 @@ namespace PSManagement.Application.Tracks.Common ...@@ -6,7 +6,7 @@ namespace PSManagement.Application.Tracks.Common
public class EmployeeTrackDTO public class EmployeeTrackDTO
{ {
public int Id { get; set; } public int Id { get; set; }
public int EmloyeeId { get; set; } public int EmployeeId { get; set; }
public EmployeeDTO Employee { get; set; } public EmployeeDTO Employee { get; set; }
public int TrackId { get; set; } public int TrackId { get; set; }
public TrackInfo TrackInfo { get; set; } public TrackInfo TrackInfo { get; set; }
......
...@@ -56,6 +56,11 @@ namespace PSManagement.Application.Tracks.UseCaes.Commands.CompleteTrack ...@@ -56,6 +56,11 @@ namespace PSManagement.Application.Tracks.UseCaes.Commands.CompleteTrack
} }
if (track.CheckEmployeeTrack()) {
return Result.Invalid(TracksErrors.InvailEmployeeTrack);
}
foreach (StepTrack stepTrack in track?.StepTracks) { foreach (StepTrack stepTrack in track?.StepTracks) {
Step step =await _stepsRepository.GetByIdAsync(stepTrack.StepId); Step step =await _stepsRepository.GetByIdAsync(stepTrack.StepId);
......
...@@ -52,10 +52,11 @@ namespace PSManagement.Application.Tracks.UseCaes.Commands.UpdateEmployeeWorkTra ...@@ -52,10 +52,11 @@ namespace PSManagement.Application.Tracks.UseCaes.Commands.UpdateEmployeeWorkTra
return Result.Invalid(TracksErrors.InvalidEntryError); return Result.Invalid(TracksErrors.InvalidEntryError);
} }
employeeTrack.UpdateEmployeeWork(request.EmployeeWork);
employeeTrack.UpdateEmployeeWorkInfo(request.EmployeeWorkInfo);
employeeTrack.UpdateNotes(request.Notes);
employeeTrack.EmployeeWork = request.EmployeeWork;
employeeTrack.EmployeeWorkInfo = request.EmployeeWorkInfo;
employeeTrack.Notes = request.Notes;
await _employeeTracksRepository.UpdateAsync(employeeTrack); await _employeeTracksRepository.UpdateAsync(employeeTrack);
......
...@@ -5,7 +5,7 @@ using PSManagement.Contracts.Projects.Response; ...@@ -5,7 +5,7 @@ using PSManagement.Contracts.Projects.Response;
namespace PSManagement.Contracts.Tracks.Response namespace PSManagement.Contracts.Tracks.Response
{ {
public record EmployeeTrackResponse( public record EmployeeTrackResponse(
int EmloyeeId, int EmployeeId,
int TrackId, int TrackId,
EmployeeResponse Employee, EmployeeResponse Employee,
TrackInfo TrackInfo, TrackInfo TrackInfo,
......
using PSManagement.SharedKernel.DomainErrors; using Ardalis.Result;
using PSManagement.SharedKernel.DomainErrors;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -15,6 +16,6 @@ namespace PSManagement.Domain.Tracking.DomainErrors ...@@ -15,6 +16,6 @@ namespace PSManagement.Domain.Tracking.DomainErrors
public static DomainError StepTrackExistError { get; } = new("TrackError.Step.Exist.", "the Project already have the given particpant Data"); public static DomainError StepTrackExistError { get; } = new("TrackError.Step.Exist.", "the Project already have the given particpant Data");
public static DomainError StepTrackUnExistError { get; } = new("TrackError.Step.UnExist.", "the Project doesnt have the given particpant Data"); public static DomainError StepTrackUnExistError { get; } = new("TrackError.Step.UnExist.", "the Project doesnt have the given particpant Data");
public static DomainError TrackCompletedUpdateError { get; } = new("TrackError.Update.complete.", "the track couldnt be update afert its completed"); public static DomainError TrackCompletedUpdateError { get; } = new("TrackError.Update.complete.", "the track couldnt be update afert its completed");
public static DomainError InvailEmployeeTrack { get; } = new("TrackError.Update.complete.", "the employee track is not correct");
} }
} }
using PSManagement.Domain.Employees.Entities; using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.Tracking.ValueObjects; using PSManagement.Domain.Tracking.ValueObjects;
using PSManagement.SharedKernel.Entities; using PSManagement.SharedKernel.Entities;
using System;
namespace PSManagement.Domain.Tracking namespace PSManagement.Domain.Tracking
{ {
...@@ -13,5 +14,23 @@ namespace PSManagement.Domain.Tracking ...@@ -13,5 +14,23 @@ namespace PSManagement.Domain.Tracking
public EmployeeWorkInfo EmployeeWorkInfo { get; set; } public EmployeeWorkInfo EmployeeWorkInfo { get; set; }
public EmployeeWork EmployeeWork { get; set; } public EmployeeWork EmployeeWork { get; set; }
public string Notes { get; set; } public string Notes { get; set; }
#region Encapsulation
public void UpdateEmployeeWork(EmployeeWork employeeWork)
{
EmployeeWork = employeeWork;
}
public void UpdateEmployeeWorkInfo(EmployeeWorkInfo employeeWorkInfo)
{
EmployeeWorkInfo = employeeWorkInfo;
}
public void UpdateNotes(string notes)
{
Notes = notes;
}
#endregion Encapsulation
} }
} }
...@@ -76,6 +76,19 @@ namespace PSManagement.Domain.Tracking ...@@ -76,6 +76,19 @@ namespace PSManagement.Domain.Tracking
}); });
}
public bool CheckEmployeeTrack()
{
int contributions = 0;
foreach (EmployeeTrack employeeTrack in EmployeeTracks) {
contributions += employeeTrack.EmployeeWork.ContributingRatio;
}
return contributions == 100;
} }
#endregion Encapsulation #endregion Encapsulation
} }
......
...@@ -77,23 +77,23 @@ namespace PSManagement.Presentation.Controllers.Steps ...@@ -77,23 +77,23 @@ namespace PSManagement.Presentation.Controllers.Steps
return HandleResult(result); return HandleResult(result);
} }
[HttpPut("UpdateStepInfo/{id}")] [HttpPut("UpdateStepInfo")]
public async Task<IActionResult> PutChangeStepInfo(ChangeStepInfoRequest request ) public async Task<IActionResult> PutChangeStepInfo(ChangeStepInfoRequest request )
{ {
var query = _mapper.Map<UpdateStepInformationCommand>(request); ; var query = _mapper.Map<UpdateStepInformationCommand>(request); ;
var result = _mapper.Map<Result>(await _sender.Send(query)); var result =await _sender.Send(query);
return HandleResult(result); return HandleResult(result);
} }
[HttpPut("ChangeCompletionRatio/{id}")] [HttpPut("ChangeCompletionRatio")]
public async Task<IActionResult> PutCompletionRatio(UpdateCompletionRatioRequest request) public async Task<IActionResult> PutCompletionRatio(UpdateCompletionRatioRequest request)
{ {
var query = _mapper.Map<UpdateCompletionRatioCommand>(request); var query = _mapper.Map<UpdateCompletionRatioCommand>(request);
var result = _mapper.Map<Result>(await _sender.Send(query)); var result =await _sender.Send(query);
return HandleResult(result); return HandleResult(result);
} }
......
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