public IActionResult EditEscort(SingleRequestEscortViewModel vm, long RequestID, int page)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var escort = vm.Escort;
             if (_repository.SaveEscort(escort))
             {
                 var req   = _repository.GetRequestByID(GetRequestorBadge(), RequestID);
                 var reqvm = SingleRequestViewModel.CreateFromRequest(req);
                 //return Escorts(reqvm, RequestID, page, vm.RequestAction);
                 return(RedirectToAction(Globals.RouteActions.Escorts, GetRouteValues(RequestID, page, vm.RequestAction)));
             }
             else
             {
                 ModelState.AddModelError("", "Unable to save escort");
                 return(View(escort));
             }
         }
         catch (Exception e)
         {
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             ModelState.AddModelError("", ExceptionHelper.ExceptionMessageToString(e));
             return(View(vm));
         }
     }
     HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
     ModelState.AddModelError("", ValidationHelper.ValidationMessageToString(ModelState));
     return(View(vm));
 }
        public IActionResult AddEscort(long RequestID, int page, string returnAction)
        {
            var req    = _repository.GetRequestByID(GetRequestorBadge(), RequestID);
            var escort = tb_request_escort.CreateRequestEscort(req);
            var vm     = SingleRequestEscortViewModel.CreateFromEscort(escort);

            vm.RequestAction = returnAction;
            vm.ReturnAction  = Globals.RouteActions.Escorts;
            return(View(vm));
        }
        public IActionResult EditEscort(long requestid, int escortno, int page, string returnAction)
        {
            var req = _repository.GetRequestByID(GetRequestorBadge(), requestid);
            var vm  = SingleRequestEscortViewModel.CreateFromEscort(req.RequestEscorts.Where(e => e.EscortNo == escortno).First());

            vm.RequestAction = returnAction;    // preserve Request workflow
            vm.ReturnAction  = Globals.RouteActions.Escorts;
            ViewBag.Page     = page;
            if (vm != null)
            {
                return(View(vm));
            }
            else
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                ModelState.AddModelError("", "Escort not found.");
                return(View(vm));
            }
        }
 public IActionResult AddEscort(SingleRequestEscortViewModel vm, long RequestID, int page)
 {
     if (ModelState.IsValid)
     {
         var escort = vm.Escort;
         try
         {
             _repository.AddEscort(escort);
             return(RedirectToAction(Globals.RouteActions.Escorts, GetRouteValues(RequestID, page, vm.RequestAction)));
         }
         catch (Exception e)
         {
             Response.StatusCode = (int)HttpStatusCode.BadRequest;
             ModelState.AddModelError("", ExceptionHelper.ExceptionMessageToString(e));
             return(View(escort));
         }
     }
     HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
     ModelState.AddModelError("", ValidationHelper.ValidationMessageToString(ModelState));
     return(View(vm.Escort));
 }