public async Task <IActionResult> Finish(DateTime planningDate, string jobId)
 {
     return(await _resiliencyHelper.ExecuteResilient(async() =>
     {
         string dateStr = planningDate.ToString("yyyy-MM-dd");
         MaintenanceJob job = await _workshopManagementAPI.GetMaintenanceJob(dateStr, jobId);
         var model = new WorkshopManagementFinishViewModel
         {
             Id = job.Id,
             Date = planningDate,
             ActualStartTime = job.StartTime,
             ActualEndTime = job.EndTime
         };
         return View(model);
     }, View("Offline", new WorkshopManagementOfflineViewModel())));
 }
 public async Task <IActionResult> Finish(DateTime date, string jobId)
 {
     return(await ExecuteWithFallback(async() =>
     {
         string dateStr = date.ToString("yyyy-MM-dd");
         MaintenanceJob job = await _workshopManagementAPI.GetMaintenanceJob(dateStr, jobId);
         var model = new WorkshopManagementFinishViewModel
         {
             Id = job.Id,
             Date = date,
             ActualStartTime = job.StartTime,
             ActualEndTime = job.EndTime
         };
         return View(model);
     }));
 }
        public async Task <IActionResult> FinishMaintenanceJob([FromForm] WorkshopManagementFinishViewModel inputModel)
        {
            if (ModelState.IsValid)
            {
                return(await _resiliencyHelper.ExecuteResilient(async() =>
                {
                    string dateStr = inputModel.Date.ToString("yyyy-MM-dd");
                    DateTime actualStartTime = inputModel.Date.Add(inputModel.ActualStartTime.Value.TimeOfDay);
                    DateTime actualEndTime = inputModel.Date.Add(inputModel.ActualEndTime.Value.TimeOfDay);

                    FinishMaintenanceJob cmd = new FinishMaintenanceJob(Guid.NewGuid(), inputModel.Id,
                                                                        actualStartTime, actualEndTime, inputModel.Notes);

                    await _workshopManagementAPI.FinishMaintenanceJob(dateStr, inputModel.Id.ToString("D"), cmd);

                    return RedirectToAction("Details", new { planningDate = dateStr, jobId = inputModel.Id });
                }, View("Offline", new WorkshopManagementOfflineViewModel())));
            }
            else
            {
                return(View("Finish", inputModel));
            }
        }