public ActionResult Create(VehiclesFleet car) { try { #region TypeToAdd VehiclesType typeToAdd = new VehiclesType(); VehiclesTypesLogic logicType = new VehiclesTypesLogic(); var type = logicType.GetOneVehicleTypeDetails(car.TypeID); typeToAdd.DailyRentCost = type.DailyRentCost; typeToAdd.Manufacturer = type.Manufacturer; typeToAdd.ManufactureYear = type.ManufactureYear; typeToAdd.Model = type.Model; typeToAdd.Picture = type.Picture; typeToAdd.RentCostForDelay = type.RentCostForDelay; typeToAdd.Transmission = type.Transmission; car.Type = typeToAdd; #endregion VehiclesFleetLogic numToCheck = new VehiclesFleetLogic(); if (!numToCheck.CheckVehicleNumber(car.CarNumber)) { ModelState.AddModelError("CarNumber", "The number already exists!"); } if (!ModelState.IsValid) { return(View()); } using (VehiclesFleetLogic logic = new VehiclesFleetLogic()) { logic.AddVehiclesToFleet(car); } return(RedirectToAction("Index", "MangeHome")); } catch { ViewBag.Error = "We have problem on the server, Please try again!"; return(View(new VehiclesFleet())); } }
public ActionResult Delete(VehiclesType deleteType) { try { if (!ModelState.IsValid) { return(View()); } using (VehiclesTypesLogic logic = new VehiclesTypesLogic()) { logic.DeleteVehicleType(deleteType); } return(RedirectToAction("Index", "MangeHome")); } catch { ViewBag.Error = "We have problem on the server, Please try again later!"; return(View(new VehiclesType())); } }
public Vehicle(VehiclesType vehicleType) { _vehicleType = vehicleType; }
/// <summary> /// Delete vehicle type /// </summary> /// <param name="Type">The details of the type to delete</param> public void DeleteVehicleType(VehiclesType Type) { DB.Entry(Type).State = EntityState.Deleted; DB.SaveChanges(); }
/// <summary> /// Edit exist vehicle type /// </summary> /// <param name="Type">The vehicle type details with the updates</param> public void EditVehicleType(VehiclesType Type) { DB.VehiclesTypes.Add(Type); DB.Entry(Type).State = EntityState.Modified; DB.SaveChanges(); }
/// <summary> /// Add new vehicle type /// </summary> /// <param name="Type">The new type details</param> public void AddVehicleType(VehiclesType Type) { DB.VehiclesTypes.Add(Type); DB.SaveChanges(); }
void Awake() { instance = this; }