public ActionResult CreateVehicleRate(VehicleRateViewModel newVehicle, string button) { try { VehicleRateViewModel model = new VehicleRateViewModel(); model.Passenger = CustomDataHelper.DataHelper.GetGuestType(); if (newVehicle.PassengerType.Equals("Hotel Staff")) { newVehicle.VehicleType = "Car/SUV"; } Domain.Trips.VehicleRate vehicleRateEntity = Mapper.Map <Domain.Trips.VehicleRate>(newVehicle); if (_vehicleRateService.VehicleExists(vehicleRateEntity.VehicleType)) { vehicleRateEntity.IsDeleted = false; _vehicleRateService.SaveVehicleRate(vehicleRateEntity); if (button.Equals("SAVE RATE")) { return(RedirectToAction("Index")); } ModelState.Clear(); ViewData["Success"] = "Successfully Added."; } else { ModelState.AddModelError("", "This Vehicle Type Already Exists"); ViewBag.PassengerTypeHide = newVehicle.PassengerType; } return(View(model)); } catch { return(View()); } }
public ActionResult EditVehicleRate(int id) { Domain.Trips.VehicleRate EntityToUpdate = _vehicleRateService.GetVehicleRateById(id); VehicleRateViewModel model = Mapper.Map <VehicleRateViewModel>(EntityToUpdate); return(View(model)); }
public ActionResult EditVehicleRate(int id, VehicleRateViewModel updatedVehicle) { try { Domain.Trips.VehicleRate vehicleRateEntity = Mapper.Map <Domain.Trips.VehicleRate>(updatedVehicle); _vehicleRateService.UpdateVehicleRate(id, vehicleRateEntity); return(RedirectToAction("Index")); } catch { return(View()); } }