Ejemplo n.º 1
0
        public ServiceResponse <int> AssaignDreiverJourneyUpdate(JourneyUpdate JourneyUpdate)
        {
            var journey = _context.Journey.Find(JourneyUpdate.JourneyId);

            journey.JourneyStatus = JourneyStatus.PendingOnDriverCompletePreTripAssessment;
            _context.Notification.Add(new Notification
            {
                CreationTime     = DateTime.Now,
                Text             = "Journey from " + journey.FromDestination + " to " + journey.ToDestination + " Assaigned to you",
                UserId           = JourneyUpdate.DriverId.Value,
                Role             = UserRoles.Driver,
                NotificationType = NotificationType.JourneyInfo,
                JourneyId        = journey.Id
            });
            if (JourneyUpdate.Id > 0)
            {
                var item = _context.JourneyUpdate.Find(JourneyUpdate.Id);
                item.VehicleNo     = JourneyUpdate.VehicleNo;
                item.DriverId      = JourneyUpdate.DriverId;
                item.StatusMessage = JourneyUpdate.StatusMessage;
                item.Date          = DateTime.Now;
                _context.SaveChanges();
                return(new ServiceResponse <int> {
                    Data = item.Id, Status = ResponseStatus.Success
                });
            }
            else
            {
                var item = _context.JourneyUpdate.Add(JourneyUpdate);
                _context.SaveChanges();
                return(new ServiceResponse <int> {
                    Data = item.Entity.Id, Status = ResponseStatus.Success
                });
            }
        }
Ejemplo n.º 2
0
 public ServiceResponse AddJourneyUpdate(JourneyUpdate JourneyUpdate)
 {
     JourneyUpdate.Date = DateTime.Now;
     _context.JourneyUpdate.Add(JourneyUpdate);
     _context.SaveChanges();
     return(new ServiceResponse {
         Status = ResponseStatus.Success
     });
 }
Ejemplo n.º 3
0
 public IActionResult AddJourneyUpdate(JourneyUpdate JourneyUpdate)
 {
     try
     {
         JourneyUpdate.CheckpointId = null;
         var result = _journeyService.AddJourneyUpdate(JourneyUpdate);
         return(Ok(result));
     }
     catch (Exception ex)
     {
         ex.LogException();
         return(Ok(new ServiceResponse {
             Status = DAL.Common.Enums.ResponseStatus.ServerError
         }));
     }
 }
Ejemplo n.º 4
0
        public ServiceResponse SubmitStatus(JourneyUpdate journeyUpdate)
        {
            ServiceResponse response = new ServiceResponse();

            try
            {
                _context.JourneyUpdate.Add(journeyUpdate);
                _context.SaveChanges();

                response.Status = ResponseStatus.Success;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Status  = ResponseStatus.ServerError;

                ExceptionLogger.LogException(ex);
            }

            return(response);
        }
Ejemplo n.º 5
0
 public IActionResult SubmitStatus(JourneyUpdate status)
 {
     return(Ok(_driverService.SubmitStatus(status)));
 }