public async Task Handle(CreateJobAssignFromJobAssignCommand message) { try { var item = await repository.Get(message.Id); if (item != null) { throw new Exception($"JobAssign task with id: {message.Id} already exist"); } } catch (AggregateNotFoundException) { // That is fine that id not used } if (message.RewriteChangedByWeeks) { CopyWeekListFromGlobalAssign(message.WeekList); } var jobAssign = JobAssignDomain.Create(message.Id, message.HousingDepartmentIdList, message.Description, message.TillYear, message.RepeatsPerWeek, message.CreatedByRole, message.ChangedByRole, message.WeekList, message.UploadList, message.DayPerWeekList, message.JobIdList, message.IsGlobal, message.IsLocked, message.JobResponsibleLIst); await repository.Save(jobAssign); }
public async Task Handle(AssignJobCommand message) { JobAssignDomain jobAssign = await repository.Get(message.Id); CreateOrUpdateJobAssign(jobAssign, message.HousingDepartmentId); await repository.Save(jobAssign); }
private void DeleteOrUpdateAssign(JobAssignDomain jobAssign, Guid departmentId) { if (jobAssign.IsGlobal) { jobAssign.RemoveDepartment(departmentId); } else { jobAssign.ChangeIsEnabled(false); } }
private void CreateOrUpdateJobAssign(JobAssignDomain jobAssign, Guid departmentId) { if (jobAssign.IsGlobal) { jobAssign.AssignDepartment(departmentId); } else { jobAssign.ChangeIsEnabled(true); } }
public async Task Handle(CreateOperationalTaskAssignCommand message) { try { var item = await repository.Get(message.Id); if (item != null) { throw new Exception($"Operational task with id: {message.Id} already exist"); } } catch (AggregateNotFoundException) { // That is fine that id not used } var jobAssign = JobAssignDomain.CreateAdHockAssign(message); await repository.Save(jobAssign); }
public async Task Handle(CreateJobAssignCommand message) { try { var item = await repository.Get(message.Id.ToString()); if (item != null) { throw new Exception($"JobAssign with id: {message.Id} already exist"); } } catch (AggregateNotFoundException) { // That is fine that id not used } var jobAssign = JobAssignDomain.Create(message.Id, new List <string> { message.JobId }, message.CreatedByRole, message.TillYear); await repository.Save(jobAssign); }