/// <summary>
        /// Sets the flag which indicates of the car is return and set rental fee if needed to be calculated.
        /// </summary>
        /// <param name="rezervationId"></param>
        /// <returns>True if the operation complete successfully</returns>
        public bool ReturnCar(int rezervationId)
        {
            var dbRezervation = this.GetRezervation(rezervationId);

            if (!dbRezervation.IsPickedUp || dbRezervation.IsCancelled)
            {
                throw new InvalidOperationException("Car has not been picked up yet, or rezervation cancelled.");
            }

            dbRezervation.IsReturned = true;

            // in case the return date is more that the one intially specified then recalucate the rental fee.
            if (dbRezervation.ReturnDate < DateTime.Now)
            {
                dbRezervation.RentaltFee = CarTypes.GetCarType((CarTypeEnum)dbRezervation.CarType).GetRentalFee(dbRezervation.PickUpDate, DateTime.Now);
            }
            dbRezervation.RentaltFee         = dbRezervation.RentaltFee;
            dbRezervation.CancelationFeeRate = 0.0m;
            dbRezervation.CancellationFee    = 0.0m;
            this.dbContext.SaveChanges();

            return(true);
        }
        /// <summary>
        /// Creates a booking for the client account.
        /// </summary>
        /// <param name="parameters">Rezervation creation parameters. Hold information on the client account and the rezervation.</param>
        /// <returns></returns>
        public RezervationModel CreateBooking(RezervationCreationParameters parameters)
        {
            this.ValidateBookingParameters(parameters);

            //try to get a client account first
            var clientAccount = this.dbContext.ClientAccounts.SingleOrDefault(x => x.ClientId == parameters.ClientId)?.ToModel();

            if (clientAccount == null && parameters.ClientAccount != null)
            {
                clientAccount = this.clientAccountService.Add(parameters.ClientAccount);
            }
            else if (parameters.ClientAccount == null && clientAccount == null)
            {
                throw new NotFoundException("Client account not found.");
            }

            var dbRezervation = new Rezervation()
            {
                ClientId       = clientAccount.ClientId,
                CarPlateNumber = parameters.CarPlateNumber,
                PickUpDate     = parameters.PickUpDate,
                ReturnDate     = parameters.ReturnDate,
            };

            //get the car type
            var carType = CarTypes.GetCarType(parameters.CarType);

            dbRezervation.CarType    = (int)carType.Type;
            dbRezervation.RentaltFee = carType.GetRentalFee(parameters.PickUpDate, parameters.ReturnDate);
            dbRezervation.DepositFee = carType.GetDepositFee(dbRezervation.RentaltFee);

            this.dbContext.Rezervations.Add(dbRezervation);
            this.dbContext.SaveChanges();

            return(dbRezervation.ToModel(clientAccount));
        }