Exemplo n.º 1
0
        /// <summary>
        /// add rental in the database, return true if it is added, otherwise
        /// return false.
        /// </summary>
        /// <param name="r"></param>
        /// <returns></returns>
        public static bool AddRental(Rental r)
        {
            List <Rental> r1 = DBController.GetAllRecords <Rental>().Where(rental =>
                                                                           rental.CustomerID == r.CustomerID).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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// add purchase in the database.
        /// </summary>
        /// <param name="p"></param>
        public static void AddPurchase(Purchase p)
        {
            Vehicle v = DBController.GetAllRecords <Vehicle>().Where(vehicle =>
                                                                     vehicle.VehicleID == p.VehicleID).FirstOrDefault();

            v.IsRented = true;
            DeterminePurchaseCost(p);
            DBController.Save(p, DBObject.SaveTypes.Insert);
            VehicleControl.ModifyVehicle(v);
        }