Commit c2f1792e authored by hasan khaddour's avatar hasan khaddour

ADD CQRS for each domain

parent bdff6c68
...@@ -10,4 +10,5 @@ namespace PSManagement.Application.Contracts.Providers ...@@ -10,4 +10,5 @@ namespace PSManagement.Application.Contracts.Providers
{ {
public DateTime UtcNow { get; } public DateTime UtcNow { get; }
} }
} }
using PSManagement.Domain.Employees.Entities;
using System.Collections.Generic;
namespace PSManagement.Application.Contracts.Providers
{
public interface IDepartmentsProvider
{
public ICollection<Department> FetchDepartments();
}
}
using PSManagement.Domain.Employees.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Application.Contracts.Providers
{
public interface IEmployeesProvider
{
public ICollection<Employee> FetchEmployees();
}
}
using PSManagement.Application.Contracts.Providers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Application.Contracts.SyncData
{
public interface ISyncEmployeesService
{
public void SyncEmployees(IEmployeesProvider employeesProvider);
}
public interface ISyncDepartmentsService
{
public void SyncEmployees(IEmployeesProvider employeesProvider);
}
}
...@@ -5,6 +5,7 @@ using PSManagement.Domain.Customers.DomainEvents; ...@@ -5,6 +5,7 @@ using PSManagement.Domain.Customers.DomainEvents;
using PSManagement.Domain.Customers.Repositories; using PSManagement.Domain.Customers.Repositories;
using PSManagement.Domain.Customers.ValueObjects; using PSManagement.Domain.Customers.ValueObjects;
using PSManagement.SharedKernel.CQRS.Command; using PSManagement.SharedKernel.CQRS.Command;
using PSManagement.SharedKernel.Interfaces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
...@@ -17,10 +18,12 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer ...@@ -17,10 +18,12 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
public class CreateCustomerCommandHandler : ICommandHandler<CreateCustomerCommand, Result<int>> public class CreateCustomerCommandHandler : ICommandHandler<CreateCustomerCommand, Result<int>>
{ {
private readonly ICustomersRepository _customerRepository; private readonly ICustomersRepository _customerRepository;
private readonly IUnitOfWork _unitOfWork;
public CreateCustomerCommandHandler(ICustomersRepository customerRepository)
public CreateCustomerCommandHandler(ICustomersRepository customerRepository, IUnitOfWork unitOfWork)
{ {
_customerRepository = customerRepository; _customerRepository = customerRepository;
_unitOfWork = unitOfWork;
} }
public async Task<Result<int>> Handle(CreateCustomerCommand request, CancellationToken cancellationToken) public async Task<Result<int>> Handle(CreateCustomerCommand request, CancellationToken cancellationToken)
{ {
...@@ -30,7 +33,7 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer ...@@ -30,7 +33,7 @@ namespace PSManagement.Application.Customers.UseCases.Commands.CreateCustomer
customer =await _customerRepository.AddAsync(customer); customer =await _customerRepository.AddAsync(customer);
customer.AddDomainEvent(new CutsomerCreatedEvent(customer.Id ,customer.CustomerName)); customer.AddDomainEvent(new CutsomerCreatedEvent(customer.Id ,customer.CustomerName));
await _unitOfWork.SaveChangesAsync();
return Result.Ok(customer.Id); return Result.Ok(customer.Id);
} }
......
...@@ -6,30 +6,53 @@ ...@@ -6,30 +6,53 @@
<ItemGroup> <ItemGroup>
<Folder Include="Behaviors\AuthorizationBehavior\" /> <Folder Include="Behaviors\AuthorizationBehavior\" />
<Folder Include="Employees\UseCases\Commands\UpdateEmployeeWorkHours\" />
<Folder Include="Employees\UseCases\Queries\GetEmployeeWorkingHours\" />
<Folder Include="Employees\UseCases\Queries\GetEmployeeProjects\" />
<Folder Include="Employees\UseCases\Queries\GetAvailableEmployees\" />
<Folder Include="Employees\UseCases\Queries\GetEmployeeParticipations\" />
<Folder Include="FinancialSpending\UseCases\Commands\CreateFinancialSpendingItem\" />
<Folder Include="FinancialSpending\UseCases\Commands\" />
<Folder Include="FinancialSpending\UseCases\Commands\UpateFinancialSpendingItem\" />
<Folder Include="FinancialSpending\UseCases\Queries\GetFinancialSpendingByProject\" />
<Folder Include="FinancialSpending\UseCases\Queries\GetFinancialSpendingById\" />
<Folder Include="ProjectsStatus\UseCases\" /> <Folder Include="ProjectsStatus\UseCases\" />
<Folder Include="Projects\UseCases\Commands\AddStep\" /> <Folder Include="Projects\EventsHandlers\" />
<Folder Include="Projects\UseCases\Commands\AddFinincialSpending\" /> <Folder Include="Projects\UseCases\Commands\AddProjectPlan\" />
<Folder Include="Projects\UseCases\Commands\AddParticipant\" /> <Folder Include="Projects\UseCases\Commands\AddParticipant\" />
<Folder Include="Projects\UseCases\Commands\ApproveProject\" />
<Folder Include="Projects\UseCases\Commands\ChangeProjectTeamLeader\" />
<Folder Include="Projects\UseCases\Commands\RemoveParticipant\" />
<Folder Include="Projects\UseCases\Commands\UpdateParticipant\" /> <Folder Include="Projects\UseCases\Commands\UpdateParticipant\" />
<Folder Include="Projects\UseCases\Commands\UpdateFinincialSpending\" /> <Folder Include="Projects\UseCases\Commands\AddAttachment\" />
<Folder Include="Projects\UseCases\Commands\UpdateProject\" />
<Folder Include="Projects\UseCases\Commands\UpdateStep\" /> <Folder Include="Projects\UseCases\Commands\UpdateStep\" />
<Folder Include="Projects\UseCases\Queries\ListAllProject\" /> <Folder Include="Projects\UseCases\Queries\ListAllProject\" />
<Folder Include="Projects\UseCases\Queries\GetProjectPlan\" /> <Folder Include="Projects\UseCases\Queries\GetProjectPlan\" />
<Folder Include="Projects\UseCases\Queries\GetProject\" /> <Folder Include="Projects\UseCases\Queries\GetProject\" />
<Folder Include="Projects\UseCases\Queries\GetProjectFinicialSpending\" /> <Folder Include="Projects\UseCases\Queries\GetProjectFinicialSpending\" />
<Folder Include="Projects\UseCases\Queries\GetParticipants\" />
<Folder Include="Reports\UseCases\" />
<Folder Include="Reports\UseCases\Queries\" />
<Folder Include="Steps\UseCases\Commands\ChangeStepWeight\" />
<Folder Include="Steps\UseCases\Commands\UpdateCompletionRatio\" />
<Folder Include="Steps\UseCases\Commands\UpdateStepRequiredWorkers\" />
<Folder Include="Steps\UseCases\Commands\RemoveStep\" />
<Folder Include="Steps\UseCases\Queries\GetStep\" />
<Folder Include="Steps\UseCases\Queries\GetStepHistory\" />
<Folder Include="Tracks\UseCaes\Commands\CreateTrack\" /> <Folder Include="Tracks\UseCaes\Commands\CreateTrack\" />
<Folder Include="Tracks\UseCaes\Commands\AddStepsTrack\" /> <Folder Include="Tracks\UseCaes\Commands\AddStepsTrack\" />
<Folder Include="Tracks\UseCaes\Commands\AddEmployeesTrack\" /> <Folder Include="Tracks\UseCaes\Commands\AddEmployeesTrack\" />
<Folder Include="Tracks\UseCaes\Commands\RemoveTrack\" />
<Folder Include="Tracks\UseCaes\Commands\SaveTrack\" /> <Folder Include="Tracks\UseCaes\Commands\SaveTrack\" />
<Folder Include="Tracks\UseCaes\Commands\UpdateEmployeeTrack\" /> <Folder Include="Tracks\UseCaes\Commands\UpdateEmployeeTrack\" />
<Folder Include="Tracks\UseCaes\Commands\UpdateStepTrack\" /> <Folder Include="Tracks\UseCaes\Commands\UpdateStepTrack\" />
<Folder Include="Tracks\UseCaes\Commands\UpdateTrack\" /> <Folder Include="Tracks\UseCaes\Commands\UpdateTrack\" />
<Folder Include="Tracks\UseCaes\Queries\ListAll\" /> <Folder Include="Tracks\UseCaes\Queries\GetTrackById\" />
<Folder Include="Tracks\UseCaes\Queries\GetTrack\" /> <Folder Include="Tracks\UseCaes\Queries\GetTracksByProject\" />
<Folder Include="Tracks\UseCaes\Queries\GetPlanTrack\" /> <Folder Include="Tracks\UseCaes\Queries\GetPlanTrack\" />
<Folder Include="Tracks\UseCaes\Queries\GetEmployeesTrack\" /> <Folder Include="Tracks\UseCaes\Queries\GetEmployeesTrack\" />
<Folder Include="Tracks\UseCaes\Queries\GetEmployeeTrack\" /> <Folder Include="Tracks\UseCaes\Queries\GetEmployeeTrack\" />
<Folder Include="Tracks\UseCaes\Queries\GetStepTracks\" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -17,4 +17,5 @@ namespace PSManagement.Application.Projects.UseCases.Commands.CreateProject ...@@ -17,4 +17,5 @@ namespace PSManagement.Application.Projects.UseCases.Commands.CreateProject
int ProjectManagerId, int ProjectManagerId,
int ProposerId int ProposerId
) : ICommand<Result<ProjectDTO>>; ) : ICommand<Result<ProjectDTO>>;
} }
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