public ServiceResponse SubmitAssessment(int journeyId, int?journeyUpdateId, JourneyStatus status, List <AssessmentResult> assessmentResult) { ServiceResponse response = new ServiceResponse(); try { var journey = _context.Journey.Find(journeyId); journey.JourneyStatus = status; if (journeyUpdateId.HasValue && journeyUpdateId.Value != 0) { var journeyUpdate = _context.JourneyUpdate.Find(journeyUpdateId); journeyUpdate.JourneyStatus = JourneyStatus.PendingOnJMCApproveDriverCheckpointAssessment; } if (assessmentResult.Count > 0) { _context.AssessmentResult.AddRange(assessmentResult); } _context.SaveChanges(); response.Status = ResponseStatus.Success; } catch (Exception ex) { response.Message = ex.Message; response.Status = ResponseStatus.ServerError; ExceptionLogger.LogException(ex); } return(response); }
public ServiceResponse UpdateJourneyCheckpoint(int journeyUpdateId, JourneyStatus status) { var journey = _context.JourneyUpdate.Find(journeyUpdateId); journey.JourneyStatus = status; _context.SaveChanges(); return(new ServiceResponse { Status = ResponseStatus.Success }); }
public IActionResult UpdateJourneyStatus(int journeyId, JourneyStatus status) { try { var result = _journeyService.UpdateJourneyStatus(journeyId, status); return(Ok(result)); } catch (Exception ex) { ex.LogException(); return(Ok(new ServiceResponse { Status = DAL.Common.Enums.ResponseStatus.ServerError })); } }
public ServiceResponse UpdateJourneyStatus(int journeyId, JourneyStatus status) { var journey = _context.Journey.Find(journeyId); var countjourneyUpdates = _context.JourneyUpdate.Where(x => x.JourneyStatus == JourneyStatus.PendingOnDriverCompleteCheckpointAssessment && x.JourneyId == journeyId).Count(); if (journey.JourneyStatus == JourneyStatus.PendingOnJMCApproveDriverCheckpointAssessment && countjourneyUpdates == 1) { var ju = _context.JourneyUpdate.Where(x => x.JourneyStatus == JourneyStatus.PendingOnDriverCompleteCheckpointAssessment && x.JourneyId == journeyId).FirstOrDefault(); ju.JourneyStatus = JourneyStatus.PendingOnJMCApproveDriverCheckpointAssessment; journey.JourneyStatus = JourneyStatus.PendingOnDriverCompletePostTripAssessment; } else { journey.JourneyStatus = status; } if (countjourneyUpdates == 0 && journey.JourneyStatus != JourneyStatus.PendingOnDriverCompletePreTripAssessment) { journey.JourneyStatus = JourneyStatus.PendingOnDriverCompletePostTripAssessment; } if (status == JourneyStatus.PendingOnDriverCompleteCheckpointAssessment) { var jupdates = _context.JourneyUpdate.FirstOrDefault(x => x.JourneyId == journeyId && x.DriverId != null); if (jupdates != null) { var driver = _context.Users.Find(jupdates.DriverId); driver.IsInProgress = true; } } if (status == JourneyStatus.JourneyCompleted) { var jupdates = _context.JourneyUpdate.FirstOrDefault(x => x.JourneyId == journeyId && x.DriverId != null); var driver = _context.Users.Find(jupdates.DriverId); driver.IsInProgress = false; driver.LastCompletionTrip = DateTime.Now; } _context.SaveChanges(); return(new ServiceResponse { Status = ResponseStatus.Success }); }
public bool CheckStatus(Guid participationId, JourneyStatus status) { var participationDto = _participationManager.FindById(participationId); return(participationDto.JourneyStatus == status.ToString()); }
public IActionResult SubmitAssessment(int journeyId, int?ju, JourneyStatus status, List <AssessmentResult> assessmentResult) { return(Ok(_driverService.SubmitAssessment(journeyId, ju, status, assessmentResult))); }