public static void AddPurchase(Purchase p) { Vehicle v = DBController.GetAllRecords <Vehicle>().Where(vehicle => vehicle.VehicleID == p.VehicleID).FirstOrDefault(); v.IsRented = true; DBController.Save(p, DBObject.SaveTypes.Insert); VehicleControl.ModifyVehicle(v); }
public static bool AddRental(Rental r) { List <Rental> r1 = DBController.GetAllRecords <Rental>().Where(rental => rental.CustomerID == r.CustomerID || rental.VehicleID == r.VehicleID).ToList(); bool noneActive = true; foreach (Rental item in r1) { if (item.Active) { noneActive = false; } } if (r1 == null || noneActive) { r.Active = true; Vehicle v = DBController.GetAllRecords <Vehicle>().Where(vehicle => vehicle.VehicleID == r.VehicleID).FirstOrDefault(); v.IsRented = true; DBController.Save(r, DBObject.SaveTypes.Insert); VehicleControl.ModifyVehicle(v); return(true); } return(false); }