示例#1
0
        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);
        }
示例#2
0
        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
         }));
     }
 }
示例#4
0
        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
            });
        }
示例#5
0
        public bool CheckStatus(Guid participationId, JourneyStatus status)
        {
            var participationDto = _participationManager.FindById(participationId);

            return(participationDto.JourneyStatus == status.ToString());
        }
示例#6
0
 public IActionResult SubmitAssessment(int journeyId, int?ju, JourneyStatus status, List <AssessmentResult> assessmentResult)
 {
     return(Ok(_driverService.SubmitAssessment(journeyId, ju, status, assessmentResult)));
 }