Example #1
0
        public float CalculateCost(int days, int mileage, RentalCategory category)
        {
            switch (category)
            {
            case RentalCategory.COMPACT:
                return(price.CompactPrice);

                break;

            case RentalCategory.PREMIUM:
                price.NumberOfDays       = days;
                price.NumberOfKilometers = mileage;
                return(price.PremiumPrice);

                break;

            case RentalCategory.MINIVAN:
                price.NumberOfDays       = days;
                price.NumberOfKilometers = mileage;
                return(price.MinivanPrice);

                break;

            default:
                return(0f);

                break;
            }
        }
Example #2
0
        public void RentCar(Car car, RentalCategory category, string socialsecuritynumber, CarRentalDBContext db)
        {
            var resevation = new Resevation();
            var customer   = new Customer();

            resevation.CarId               = car.Id;
            resevation.Car                 = car;
            resevation.RentalCategory      = category;
            resevation.BookingNumber       = random.Next(1, 999999);
            resevation.CustomerId          = customer.Id;
            resevation.BookingDate         = DateTime.Now;
            customer.SocialSercurityNumber = socialsecuritynumber;
            car.IsRented = true;
            db.Update(car);
            db.Add(customer);
            db.Add(resevation);
            db.SaveChanges();
            Console.WriteLine($"You have rented the car with booking number {resevation.BookingNumber}");
        }