Esempio n. 1
0
        /// <summary>
        /// Set the car to be avalible (when a rent is finished)
        /// </summary>
        /// <param name="license"></param>
        public void SetCarAvalibility(int license)
        {
            Cars_for_Rent for_Rent = rentalCardb.Cars_for_Rents.FirstOrDefault(avalibleCar => avalibleCar.License == license);

            if (for_Rent != null)
            {
                IsAvalible          = !for_Rent.IsAvalible;
                for_Rent.IsAvalible = IsAvalible;
                rentalCardb.SaveChanges();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets all cartype info that is associated with the car by license
        /// </summary>
        /// <param name="license"></param>
        /// <returns></returns>
        public CarsForRent GetCarInfo(int license)
        {
            Cars_for_Rent for_Rent = rentalCardb.Cars_for_Rents.FirstOrDefault(avalibleCar => avalibleCar.License == license);
            CarsForRent   car      = new CarsForRent();

            car.CarUsage      = for_Rent.Distance_Usage;
            car.IsUsable      = for_Rent.IsUsable;
            car.IsAvalible    = for_Rent.IsAvalible;
            car.LicenseNumber = for_Rent.License;
            car.Lot           = for_Rent.Branch_Id;
            car.CarType       = for_Rent.Car_Type_Id;
            car.Image         = for_Rent.CarImage;
            return(car);
        }
Esempio n. 3
0
        /// <summary>
        /// Deletes car from database by license
        /// </summary>
        /// <param name="license"></param>
        /// <returns></returns>
        public bool DeleteCar(int license)
        {
            bool isDeleted = false;

            try
            {
                Cars_for_Rent carDeleting = rentalCardb.Cars_for_Rents.FirstOrDefault(avalibleCar => avalibleCar.License == license);

                rentalCardb.Cars_for_Rents.Remove(carDeleting);
                rentalCardb.SaveChanges();
                isDeleted = true;
            }
            catch (Exception msg)
            {
                Console.WriteLine(msg);
                isDeleted = false;
            }
            return(isDeleted);
        }