Example #1
0
        public ActionResult Update(long id)
        {
            var result = _emergencyRest.Find(new EmergencyFilter {
                Id = id
            });

            if (!result.Success)
            {
                LoadBag();
                ViewBag.Error = new List <string> {
                    result?.Messages?.FirstOrDefault() ?? "Ocorreu um erro, favor tente novamente."
                };
                return(View("index", new EmergencyModel()));
            }
            var requesterResult = _requesterService.Find(new RequesterFilter {
                Telephone = result.Model.RequesterPhone
            });

            if (requesterResult.Success && requesterResult?.Model?.AddressModel != null)
            {
                result.Model.AddressModel    = requesterResult?.Model?.AddressModel;
                result.Model.AddressModel.Id = 0;
            }
            LoadBag();
            return(View("index", result.Model));
        }
Example #2
0
        public IActionResult Update(long emergencyId, long emergencyRequiredVehicleId)
        {
            var result = _emergencyRest.Find(new EmergencyFilter {
                Id = emergencyId
            });

            if (!result.Success)
            {
                LoadBag();
                ViewBag.Error = new List <string> {
                    result?.Messages?.FirstOrDefault() ?? "Ocorreu um erro, favor tente novamente."
                };
                return(View("Index", new EmergencyModel()));
            }

            var requeridVehicle = result.Model.EmergencyRequiredVehicleModels.FirstOrDefault(d => d.Id == emergencyRequiredVehicleId);

            ViewBag.VehiclesAvaiable = _vehicleRest.FindAll(new VehicleFilter
            {
                Active        = Active.Active,
                VehicleStatus = VehicleStatus.Cleared,
                VehicleType   = requeridVehicle.VehicleType
            }).Model;

            ViewBag.EmergencyRequiredVehicleId = emergencyRequiredVehicleId;
            result.Model.ServiceHistoryModels  = null;

            LoadBag();
            return(View("Index", result.Model));
        }
        public IActionResult Finish(long emergencyId)
        {
            var result = _emergencyRest.Finish(new EmergencyModel {
                Id = emergencyId
            });

            if (!result.Success)
            {
                ViewBag.Error = result.Messages;
                LoadBag();
                var resultEmergency = _emergencyRest.Find(new EmergencyFilter {
                    Id = emergencyId
                });
                return(View("Index", resultEmergency.Model));
            }

            return(RedirectToAction("index"));
        }