public async Task <IActionResult> GetByDate(DateTime date) { var planning = await _planningRepo.GetWorkshopPlanningAsync(date); if (planning == null) { return(NotFound()); } return(Ok(planning)); }
public async Task <WorkshopPlanning> HandleCommandAsync(DateTime planningDate, UpdateMaintenanceJob command) { // get or create workshop-planning WorkshopPlanning planning = await planningRepository.GetWorkshopPlanningAsync(planningDate); if (planning == null) { return(null); } // handle command planning.UpdateMaintenanceJob(command); // persist IEnumerable <Event> events = planning.GetEvents(); await planningRepository.SaveWorkshopPlanningAsync( planning.Id, planning.OriginalVersion, planning.Version, events); // publish event foreach (var e in events) { await messagePublisher.PublishMessageAsync(e.MessageType, e, ""); } // return result return(planning); }
public async Task <WorkshopPlanning> HandleCommandAsync(DateTime planningDate, PlanMaintenanceJob command) { List <Event> events = new List <Event>(); // get or create workshop-planning WorkshopPlanning planning = await _planningRepo.GetWorkshopPlanningAsync(planningDate); if (planning == null) { events.AddRange(WorkshopPlanning.Create(planningDate, out planning)); } // handle command events.AddRange(planning.PlanMaintenanceJob(command)); // persist await _planningRepo.SaveWorkshopPlanningAsync( planning.Id, planning.OriginalVersion, planning.Version, events); // publish event foreach (var e in events) { await _messagePublisher.PublishMessageAsync(e.MessageType, e, ""); } // return result return(planning); }
public async Task <WorkshopPlanning> HandleCommandAsync(DateTime planningDate, FinishMaintenanceJob command) { // get planning WorkshopPlanning planning = await _planningRepo.GetWorkshopPlanningAsync(planningDate); if (planning == null) { return(null); } // handle command IEnumerable <Event> events = planning.FinishMaintenanceJob(command); // persist await _planningRepo.SaveWorkshopPlanningAsync(planning, events); // publish event foreach (var e in events) { await _messagePublisher.PublishMessageAsync(e.MessageType, e, ""); } // return result return(planning); }
public async Task <IActionResult> GetByDate(DateTime planningDate) { try { var planning = await _planningRepo.GetWorkshopPlanningAsync(planningDate); if (planning == null) { return(NotFound()); } return(Ok(planning)); } catch (Exception ex) { Log.Error(ex.ToString()); throw; } }