示例#1
0
        public static void DeterminePurchaseCost(Purchase p)
        {
            int     vehicleId = p.VehicleID;
            Vehicle v         = DBController.GetAllRecords <Vehicle>().Where(vehicle => vehicle.VehicleID == vehicleId).FirstOrDefault();
            int     totalCost = VehicleControl.DeterminePrice(v);

            p.Cost = totalCost;
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }