private void UpdateRentalAccountFromBasket(RentalBasket basket) { var account = _accountService.GetAccount(basket.CustomerAccountId) as RentalAccount; foreach (RentedUnit mRentedUnit in basket.RentedUnits) { var rentedUnit = new RentedUnit { Amount = mRentedUnit.Amount, RentedDate = mRentedUnit.RentedDate, StockId = mRentedUnit.StockId, Stock = _stockService.GetStock(mRentedUnit.StockId), Deposit = basket.FullPayment ? mRentedUnit.Deposit : 0, PaidUntil = mRentedUnit.RentedDate, }; _accountService.AddRentedUnit(account.CustomerAccountId, rentedUnit); } foreach (var oneOffItem in basket.OneOffItems) { var newOneOffItem = new OneOffItem { Description = oneOffItem.Description, Charge = oneOffItem.Charge, Date = basket.StartDate, Quantity = oneOffItem.Quantity, OneOffTypeId = oneOffItem.OneOffTypeId }; account.OneOffItems.Add(newOneOffItem); } _accountService.UpdateAccount(account); }
private void SetRentalBasketUnitsLifeCycle(RentalBasket rentalBasket, ProductLifeCycleStatus productLifeCycleStatus) { if (rentalBasket.RentedUnits == null) { return; } SetRentalStockLifeCycle(rentalBasket.RentedUnits, productLifeCycleStatus); }
public override ActionResult AddUnitBasket(int customerAccountId) { var basket = new RentalBasket { CustomerAccountId = customerAccountId }; _accountService.AddBasket(basket); _accountService.CommitChanges(); BasketId = basket.BasketId; BuildRentAccountStepper(); return(RedirectToAction(Stepper2.FirstStep())); }
private void UpdateTransactionsFromBasket(RentalBasket basket) { foreach (var rental in basket.RentedUnits) { _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Rental, rental.Amount, AccountTransactionInputType.Charge, rental.StockId, rental.Stock.ManufacturerModel); _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Deposit, rental.Deposit, AccountTransactionInputType.Charge, rental.StockId, rental.Stock.ManufacturerModel); if (basket.FullPayment) { _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Rental, -rental.Amount, AccountTransactionInputType.Payment, rental.StockId, rental.Stock.ManufacturerModel); _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Deposit, -rental.Deposit, AccountTransactionInputType.Payment, rental.StockId, rental.Stock.ManufacturerModel); } } _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.OneOff, basket.TotalOneOffItems, AccountTransactionInputType.Charge); if (basket.FullPayment) { _accountTransactionService.AddAccountPaymentTransaction(basket.CustomerAccountId, AccountTransactionType.OneOff, -basket.TotalOneOffItems); } }