public async Task <CreateOperationalTaskViewModel> CreateAdHocTask(IOperationalTaskModel model) { model.JobId = await taskIdGenerator.AdHoc(); var addressList = new List <JobAddress>(); addressList.Add(new JobAddress { HousingDepartmentId = model.DepartmentId, Address = model.Address }); await messageBus.Publish(new CreateJobCommand(model.JobId, model.CategoryId, model.Title, JobTypeEnum.AdHock, model.CreatorId, RoleType.Coordinator, addressList, null, null)); var jobAssignId = Guid.NewGuid(); CreateOperationalTaskAssignCommand adHockAssignCommand = GetCreateOperationalTaskAssignCommand(model, model.JobId, jobAssignId); await messageBus.Publish(adHockAssignCommand); var dayAssignId = Guid.NewGuid(); CreateDayAssignCommand dayAssign = GetCreateDayAssignCommand(model, dayAssignId, jobAssignId); await messageBus.Publish(dayAssign); await SetStatusAfterCreation(dayAssignId, model.TeamLeadId); CreateOperationalTaskViewModel result = new CreateOperationalTaskViewModel { Id = model.JobId, DayAssignId = dayAssignId, DepartmentId = model.DepartmentId }; return(result); }
public async Task <CreateOperationalTaskViewModel> CreateOtherTask(IOperationalTaskModel model) { int weekNumber = CalendarHelper.GetWeekNumber(model.Date.Value); model.JobId = await taskIdGenerator.Other(); var addressList = new List <JobAddress>(); addressList.Add(new JobAddress { HousingDepartmentId = model.DepartmentId, Address = model.Address }); await messageBus.Publish(new CreateJobCommand(model.JobId, Guid.Empty, model.Title, JobTypeEnum.Other, model.CreatorId, RoleType.Coordinator, addressList, null, null)); var jobAssignId = Guid.NewGuid(); CreateOperationalTaskAssignCommand tenantkAssignCommand = GetCreateOperationalTaskAssignCommand(model, model.JobId, jobAssignId, weekNumber); await messageBus.Publish(tenantkAssignCommand); var dayAssignId = Guid.NewGuid(); CreateDayAssignCommand dayAssign = GetCreateDayAssignCommand(model, dayAssignId, jobAssignId, weekNumber); await messageBus.Publish(dayAssign); await SetStatusAfterCreation(dayAssignId, model.TeamLeadId); CreateOperationalTaskViewModel result = new CreateOperationalTaskViewModel { Id = model.JobId, DepartmentId = model.DepartmentId, DayAssignId = dayAssignId }; return(result); }
private CreateOperationalTaskAssignCommand GetCreateOperationalTaskAssignCommand(IOperationalTaskModel model, string jobId, Guid assignId, int weekNumber) { var result = new CreateOperationalTaskAssignCommand(assignId, new List <string> { jobId }, RoleType.Coordinator, weekNumber) { DepartmentId = model.DepartmentId, RepeatsPerWeek = DefaultRepeatsPerWeekConst, Description = model.Description, IsEnabled = true }; return(result); }
public JobAssignDomain(CreateOperationalTaskAssignCommand message) { Id = message.Id; RaiseEvent(new AdHockJobAssignCreatedEvent { DepartmentId = message.DepartmentId, TillYear = message.TillYear, Description = message.Description, RepeatsPerWeek = message.RepeatsPerWeek, WeekList = message.WeekList, JobIdList = message.JobIdList, CreatedByRole = message.CreatedByRole, IsEnabled = message.IsEnabled }); }
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 static JobAssignDomain CreateAdHockAssign(CreateOperationalTaskAssignCommand message) { return(new JobAssignDomain(message)); }