Commit 7403cb9a authored by hasan khaddour's avatar hasan khaddour

fix overflow loop

parent b68de4f1
using AutoMapper;
using PSManagement.Application.FinancialSpends.Common;
using PSManagement.Application.FinancialSpends.UseCases.Commands.CreateFinancialSpendItem;
using PSManagement.Domain.FinancialSpends.Entities;
namespace PSManagement.Application.Mappers
{
public class FinanialSpendingDTOMapperConfiguration : Profile {
public FinanialSpendingDTOMapperConfiguration()
{
CreateMap<FinancialSpendingDTO, FinancialSpending>().ReverseMap();
CreateMap<CreateFinancialSpendItemCommand, FinancialSpending>()
.ForMember(d => d.Id, op => op.Ignore())
.ForMember(d => d.Events, op => op.Ignore())
.ConstructUsing(src => new FinancialSpending(
src.ProjectId,
src.LocalPurchase,
src.ExternalPurchase,
src.CostType,
src.Description,
src.ExpectedSpendingDate
))
;
}
}
}
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
using PSManagement.Application.Contracts.Authentication; 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.FinancialSpends.Common;
using PSManagement.Application.FinancialSpends.UseCases.Commands.CreateFinancialSpendItem;
using PSManagement.Application.Projects.Common; using PSManagement.Application.Projects.Common;
using PSManagement.Application.Projects.UseCases.Commands.CompleteProgressProject; using PSManagement.Application.Projects.UseCases.Commands.CompleteProgressProject;
using PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType; using PSManagement.Application.ProjectsTypes.UseCases.Commands.CreateNewType;
...@@ -16,7 +14,6 @@ using PSManagement.Application.Tracks.UseCaes.Commands.CreateTrack; ...@@ -16,7 +14,6 @@ using PSManagement.Application.Tracks.UseCaes.Commands.CreateTrack;
using PSManagement.Domain.Customers.Entities; using PSManagement.Domain.Customers.Entities;
using PSManagement.Domain.Customers.ValueObjects; using PSManagement.Domain.Customers.ValueObjects;
using PSManagement.Domain.Employees.Entities; using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.FinancialSpends.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.Projects.ValueObjects;
...@@ -91,32 +88,10 @@ namespace PSManagement.Application.Mappers ...@@ -91,32 +88,10 @@ namespace PSManagement.Application.Mappers
CreateMap<CreateNewTypeCommand, ProjectType>(); CreateMap<CreateNewTypeCommand, ProjectType>();
CreateMap<UpdateTypeCommand, ProjectType>(); CreateMap<UpdateTypeCommand, ProjectType>();
CreateMap <CompleteProjectCommand, ProjectCompletion>();
}
}
public class FinanialSpendingDTOMapperConfiguration : Profile {
CreateMap<ParticipationChange, ParticipationChangeDTO>().ReverseMap();
public FinanialSpendingDTOMapperConfiguration() CreateMap <CompleteProjectCommand, ProjectCompletion>();
{
CreateMap<FinancialSpendingDTO, FinancialSpending>().ReverseMap();
CreateMap<CreateFinancialSpendItemCommand, FinancialSpending>()
.ForMember(d => d.Id, op => op.Ignore())
.ForMember(d => d.Events, op => op.Ignore())
.ConstructUsing(src => new FinancialSpending(
src.ProjectId,
src.LocalPurchase,
src.ExternalPurchase,
src.CostType,
src.Description,
src.ExpectedSpendingDate
))
;
} }
} }
......
...@@ -24,8 +24,4 @@ ...@@ -24,8 +24,4 @@
<ProjectReference Include="..\PSManagement.SharedKernel\PSManagement.SharedKernel.csproj" /> <ProjectReference Include="..\PSManagement.SharedKernel\PSManagement.SharedKernel.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Projects\UseCases\Queries\GetParticipationChangeHistory\" />
</ItemGroup>
</Project> </Project>
...@@ -12,4 +12,5 @@ namespace PSManagement.Application.Projects.Common ...@@ -12,4 +12,5 @@ namespace PSManagement.Application.Projects.Common
public int PartialTimeRatio { get; set; } public int PartialTimeRatio { get; set; }
public string Role { get; set; } public string Role { get; set; }
} }
} }
\ No newline at end of file
using System;
namespace PSManagement.Application.Projects.Common
{
public class ParticipationChangeDTO
{
public int EmployeeId { get; set; }
public int ProjectId { get; set; }
public int PartialTimeBefore { get; set; }
public int PartialTimeAfter { get; set; }
public string RoleBefore { get; set; }
public string RoleAfter { get; set; }
public DateTime ChangeDate { get; set; }
}
}
\ No newline at end of file
...@@ -35,8 +35,6 @@ namespace PSManagement.Application.Projects.EventsHandlers ...@@ -35,8 +35,6 @@ namespace PSManagement.Application.Projects.EventsHandlers
}); });
await _unitOfWork.SaveChangesAsync();
} }
} }
......
using PSManagement.Application.Contracts.Email; using PSManagement.Application.Contracts.Email;
using PSManagement.Domain.Employees.Entities; using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.Employees.Repositories; using PSManagement.Domain.Employees.Repositories;
using PSManagement.Domain.Employees.Specification;
using PSManagement.Domain.Projects.DomainEvents; using PSManagement.Domain.Projects.DomainEvents;
using PSManagement.SharedKernel.DomainEvents; using PSManagement.SharedKernel.DomainEvents;
using PSManagement.SharedKernel.Specification; using PSManagement.SharedKernel.Specification;
...@@ -19,6 +20,7 @@ namespace PSManagement.Application.Projects.EventsHandlers ...@@ -19,6 +20,7 @@ namespace PSManagement.Application.Projects.EventsHandlers
{ {
_emailService = emailService; _emailService = emailService;
_employeeRepository = employeeRepository; _employeeRepository = employeeRepository;
_specification = new EmployeesSpecification();
} }
public async Task Handle(ParticipationChangedEvent notification, CancellationToken cancellationToken) public async Task Handle(ParticipationChangedEvent notification, CancellationToken cancellationToken)
......
using Ardalis.Result;
using PSManagement.Application.Projects.Common;
using PSManagement.SharedKernel.CQRS.Query;
using PSManagement.SharedKernel.Specification;
using System.Collections.Generic;
namespace PSManagement.Application.Projects.UseCases.Queries.GetParticipationChangeHistory
{
public record GetParticipationChangeHistoryQuery(
int ProjectId
) : IQuery<Result<IEnumerable<ParticipationChangeDTO>>>;
}
using Ardalis.Result;
using AutoMapper;
using PSManagement.Application.Projects.Common;
using PSManagement.Domain.Projects.Entities;
using PSManagement.SharedKernel.CQRS.Query;
using PSManagement.SharedKernel.Repositories;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace PSManagement.Application.Projects.UseCases.Queries.GetParticipationChangeHistory
{
public class GetParticipationChangeHistoryQueryHandler : IQueryHandler<GetParticipationChangeHistoryQuery, Result<IEnumerable<ParticipationChangeDTO>>>
{
private readonly IRepository<ParticipationChange> _repository;
private readonly IMapper _mapper;
public GetParticipationChangeHistoryQueryHandler(
IMapper mapper,
IRepository<ParticipationChange> repository)
{
_mapper = mapper;
_repository = repository;
}
public async Task<Result<IEnumerable<ParticipationChangeDTO>>> Handle(GetParticipationChangeHistoryQuery request, CancellationToken cancellationToken)
{
var result = await _repository.ListAsync();
result = result.Where(e => e.ProjectId == request.ProjectId);
return Result.Success(_mapper.Map<IEnumerable<ParticipationChangeDTO>>(result));
}
}
}
...@@ -15,7 +15,7 @@ namespace PSManagement.Contracts.Projects.Response ...@@ -15,7 +15,7 @@ namespace PSManagement.Contracts.Projects.Response
public ProjectClassification ProjectClassification { get; set; } public ProjectClassification ProjectClassification { get; set; }
public EmployeeResponse TeamLeader { get; set; } public EmployeeResponse TeamLeader { get; set; }
public EmployeeResponse ProjectManager { get; set; } public EmployeeResponse ProjectManager { get; set; }
public Department Executer { get; set; } public DepartmentResponse Executer { get; set; }
public CustomerResponse Proposer { get; set; } public CustomerResponse Proposer { get; set; }
......
using PSManagement.Contracts.Customers.Responses; using PSManagement.Application.Projects.Common;
using PSManagement.Contracts.Customers.Responses;
using PSManagement.Contracts.ProjectsTypes.Request; using PSManagement.Contracts.ProjectsTypes.Request;
using PSManagement.Domain.Employees.Entities; using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.Projects.Entities; using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.ValueObjects; using PSManagement.Domain.Projects.ValueObjects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace PSManagement.Contracts.Projects.Response namespace PSManagement.Contracts.Projects.Response
...@@ -28,7 +30,7 @@ namespace PSManagement.Contracts.Projects.Response ...@@ -28,7 +30,7 @@ namespace PSManagement.Contracts.Projects.Response
public int ProposerId { get; private set; } public int ProposerId { get; private set; }
public CustomerResponse Proposer { get; set; } public CustomerResponse Proposer { get; set; }
public ICollection<StepResponse> Steps { get; set; } public ICollection<StepResponse> Steps { get; set; }
public ICollection<Attachment> Attachments { get; set; } public ICollection<AttachmentReponse> Attachments { get; set; }
public FinancialFund FinancialFund { get; set; } public FinancialFund FinancialFund { get; set; }
public ICollection<FinancialSpendingResponse> FinancialSpending { get; set; } public ICollection<FinancialSpendingResponse> FinancialSpending { get; set; }
...@@ -36,4 +38,20 @@ namespace PSManagement.Contracts.Projects.Response ...@@ -36,4 +38,20 @@ namespace PSManagement.Contracts.Projects.Response
public ICollection<EmployeeParticipateResponse> EmployeeParticipates { get; set; } public ICollection<EmployeeParticipateResponse> EmployeeParticipates { get; set; }
} }
public class ParticipationChange
{
public int EmployeeId { get; set; }
public int ProjectId { get; set; }
public int PartialTimeBefore { get; set; }
public int PartialTimeAfter { get; set; }
public string RoleBefore { get; set; }
public string RoleAfter { get; set; }
public DateTime ChangeDate { get; set; }
} }
}
...@@ -100,17 +100,17 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration ...@@ -100,17 +100,17 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
} }
public class participationChangesConfiguration : IEntityTypeConfiguration<ParticipationChange> public class ParticipationChangesConfiguration : IEntityTypeConfiguration<ParticipationChange>
{ {
public void Configure(EntityTypeBuilder<ParticipationChange> builder) public void Configure(EntityTypeBuilder<ParticipationChange> builder)
{ {
builder //builder
.HasOne(e => e.Employee) // .HasO(e => e.Employee)
.WithOne(); // .WithMany();
builder //builder
.HasOne(e => e.Project) // .HasOne(e => e.Project)
.WithOne() // .WithOne()
; //;
} }
} }
......
...@@ -18,6 +18,7 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration ...@@ -18,6 +18,7 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
p.Property(e => e.StepName).HasColumnName("StepName"); p.Property(e => e.StepName).HasColumnName("StepName");
p.Property(e => e.StartDate).HasColumnName("StartDate"); p.Property(e => e.StartDate).HasColumnName("StartDate");
p.Property(e => e.Duration).HasColumnName("Duration"); p.Property(e => e.Duration).HasColumnName("Duration");
p.Property(e => e.NumberOfWorker).HasColumnName("NumberOfWorker");
} }
); );
......
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddParticipationHistory1 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_ParticipationChanges_EmployeeId",
table: "ParticipationChanges");
migrationBuilder.DropIndex(
name: "IX_ParticipationChanges_ProjectId",
table: "ParticipationChanges");
migrationBuilder.CreateIndex(
name: "IX_ParticipationChanges_EmployeeId",
table: "ParticipationChanges",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_ParticipationChanges_ProjectId",
table: "ParticipationChanges",
column: "ProjectId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_ParticipationChanges_EmployeeId",
table: "ParticipationChanges");
migrationBuilder.DropIndex(
name: "IX_ParticipationChanges_ProjectId",
table: "ParticipationChanges");
migrationBuilder.CreateIndex(
name: "IX_ParticipationChanges_EmployeeId",
table: "ParticipationChanges",
column: "EmployeeId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_ParticipationChanges_ProjectId",
table: "ParticipationChanges",
column: "ProjectId",
unique: true);
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddParticipationHistory2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "StepInfo_NumberOfWorker",
table: "Steps",
newName: "NumberOfWorker");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "NumberOfWorker",
table: "Steps",
newName: "StepInfo_NumberOfWorker");
}
}
}
...@@ -329,11 +329,9 @@ namespace PSManagement.Infrastructure.Persistence.Migrations ...@@ -329,11 +329,9 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("EmployeeId") b.HasIndex("EmployeeId");
.IsUnique();
b.HasIndex("ProjectId") b.HasIndex("ProjectId");
.IsUnique();
b.ToTable("ParticipationChanges"); b.ToTable("ParticipationChanges");
}); });
...@@ -776,14 +774,14 @@ namespace PSManagement.Infrastructure.Persistence.Migrations ...@@ -776,14 +774,14 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ParticipationChange", b => modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ParticipationChange", b =>
{ {
b.HasOne("PSManagement.Domain.Employees.Entities.Employee", "Employee") b.HasOne("PSManagement.Domain.Employees.Entities.Employee", "Employee")
.WithOne() .WithMany()
.HasForeignKey("PSManagement.Domain.Projects.Entities.ParticipationChange", "EmployeeId") .HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("PSManagement.Domain.Projects.Entities.Project", "Project") b.HasOne("PSManagement.Domain.Projects.Entities.Project", "Project")
.WithOne() .WithMany()
.HasForeignKey("PSManagement.Domain.Projects.Entities.ParticipationChange", "ProjectId") .HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
...@@ -1013,7 +1011,8 @@ namespace PSManagement.Infrastructure.Persistence.Migrations ...@@ -1013,7 +1011,8 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.HasColumnName("Duration"); .HasColumnName("Duration");
b1.Property<int>("NumberOfWorker") b1.Property<int>("NumberOfWorker")
.HasColumnType("int"); .HasColumnType("int")
.HasColumnName("NumberOfWorker");
b1.Property<DateTime>("StartDate") b1.Property<DateTime>("StartDate")
.HasColumnType("datetime2") .HasColumnType("datetime2")
......
...@@ -40,19 +40,8 @@ namespace PSManagement.Presentation.Controllers.Authentication ...@@ -40,19 +40,8 @@ namespace PSManagement.Presentation.Controllers.Authentication
registerRequest.Email, registerRequest.Email,
registerRequest.Password); registerRequest.Password);
if (result.IsSuccess) return HandleResult(_mapper.Map<Result<AuthenticationResponse>>(result));
{
AuthenticationResponse response = new(
result.Value.EmployeeId,
result.Value.FirstName,
result.Value.LastName,
result.Value.Email,
result.Value.Roles,
result.Value.Token);
return Ok(response);
}
return Problem(title: "An Errorr Occured ", detail: "", statusCode: 400);
} }
} }
......
...@@ -24,6 +24,7 @@ using PSManagement.Application.Contracts.Providers; ...@@ -24,6 +24,7 @@ using PSManagement.Application.Contracts.Providers;
using PSManagement.Application.Projects.UseCases.Commands.CancelProject; using PSManagement.Application.Projects.UseCases.Commands.CancelProject;
using PSManagement.Application.Projects.UseCases.Commands.ChangeProjectManager; using PSManagement.Application.Projects.UseCases.Commands.ChangeProjectManager;
using PSManagement.Presentation.Controllers.ApiBase; using PSManagement.Presentation.Controllers.ApiBase;
using PSManagement.Application.Projects.UseCases.Queries.GetParticipationChangeHistory;
namespace PSManagement.Presentation.Controllers.Projects namespace PSManagement.Presentation.Controllers.Projects
{ {
...@@ -57,6 +58,16 @@ namespace PSManagement.Presentation.Controllers.Projects ...@@ -57,6 +58,16 @@ namespace PSManagement.Presentation.Controllers.Projects
return HandleResult(result); return HandleResult(result);
} }
[HttpGet("ParticipationChangeHistory")]
public async Task<IActionResult> GetPartiipationChangesHistory(int id )
{
var query = new GetParticipationChangeHistoryQuery(id);
var result = await _sender.Send(query);
return HandleResult(_mapper.Map<Result<IEnumerable<ParticipationChange>>>(result));
}
[HttpGet("ByFilter")] [HttpGet("ByFilter")]
public async Task<IActionResult> GetByFilter([FromQuery] GetProjectsByFilterRequest request) public async Task<IActionResult> GetByFilter([FromQuery] GetProjectsByFilterRequest request)
......
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