Ejemplo n.º 1
0
        public ActionResult AddRentAccountStep5(AddRentAccountVM mAddRentAccountVm)
        {
            if (ModelState.IsValid)
            {
                var rentAcc = TempAccountAsAddRentAccountVM();
                if (TryUpdateModel(rentAcc))
                {
                    var newAccount = new RentalAccount
                    {
                        AlternateAddressInstructions = rentAcc.AlternateAddressInstructions,
                        AlternateAddress             = rentAcc.AlternateAddress,
                        CustomerId        = rentAcc.CustomerId,
                        AttachedContracts = new List <Contract>(),
                        RentedUnits       = new List <RentedUnit>(),
                        OneOffItems       = new List <OneOffItem>(),
                    };
                    foreach (RentedUnit mRentedUnit in rentAcc.RentedUnits)
                    {
                        var rentedUnit = new RentedUnit
                        {
                            Amount     = mRentedUnit.Amount,
                            RentedDate = mRentedUnit.RentedDate,
                            StockId    = mRentedUnit.StockId,
                            Stock      = _stockService.GetStock(mRentedUnit.StockId),
                            Deposit    = mRentedUnit.Deposit,
                        };
                        newAccount.AddRentedUnitAndUpdateContract(rentedUnit);
                    }
                    foreach (var oneOffItem in rentAcc.OneOffItems)
                    {
                        var newOneOffItem = new OneOffItem
                        {
                            Description  = oneOffItem.Description,
                            Charge       = oneOffItem.Charge,
                            Date         = rentAcc.StartDate,
                            Quantity     = oneOffItem.Quantity,
                            OneOffTypeId = oneOffItem.OneOffTypeId
                        };
                        newAccount.OneOffItems.Add(newOneOffItem);
                    }

                    if (ExecuteRepositoryAction(() =>
                    {
                        _accountService.AddTempAccount(newAccount);
                        _accountService.CommitChanges();
                    }))
                    {
                        var acceptAccount = new AcceptAccountVM
                        {
                            CustomerAccountId = newAccount.CustomerAccountId,
                            FullPayment       = (mAddRentAccountVm.Payment > 0)
                        };
                        Session["_accountId"] = acceptAccount;
                        return(RedirectToAction(Stepper2.NextStep()));
                    }
                }
            }
            return(View(mAddRentAccountVm));
        }
Ejemplo n.º 2
0
 public ActionResult AddPurchaseAccountStep7(AcceptAccountVM mAcceptAccountVm) // Accept Contract View/Print and finish
 {
     if (ModelState.IsValid)
     {
         var newAccount = _accountService.GetAccount(mAcceptAccountVm.CustomerAccountId);
         if (ExecuteRepositoryAction(() =>
         {
             newAccount.IsTemp = false;
             _accountService.UpdateAccount(newAccount);
             _accountService.CommitChanges();
         }))
         {
             return(RedirectToAction("Edit", "Customer",
                                     new
             {
                 id = newAccount.CustomerId,
                 moveOnToEditAccount = newAccount.CustomerAccountId
             }));
         }
     }
     return(View(mAcceptAccountVm));
 }
Ejemplo n.º 3
0
 public ActionResult AddRentAccountStep6(AcceptAccountVM mAcceptAccountVm) // Accept Contract View/Print and finish
 {
     if (ModelState.IsValid)
     {
         var newAccount = _accountService.GetAccount(mAcceptAccountVm.CustomerAccountId) as RentalAccount;
         if (ExecuteRepositoryAction(() =>
         {
             newAccount.IsTemp = false;
             _accountService.UpdateAccount(newAccount);
             foreach (var rental in newAccount.RentedUnits)
             {
                 _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.Rental, rental.Amount, AccountTransactionInputType.Charge, rental.StockId, rental.Stock.ManufacturerModel);
                 _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.Deposit, rental.Deposit, AccountTransactionInputType.Charge, rental.StockId, rental.Stock.ManufacturerModel);
                 if (mAcceptAccountVm.FullPayment)
                 {
                     _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.Rental, -rental.Amount, AccountTransactionInputType.Payment, rental.StockId, rental.Stock.ManufacturerModel);
                     _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.Deposit, -rental.Deposit, AccountTransactionInputType.Payment, rental.StockId, rental.Stock.ManufacturerModel);
                 }
             }
             _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.OneOff, newAccount.TotalOneOffItems, AccountTransactionInputType.Charge);
             if (mAcceptAccountVm.FullPayment)
             {
                 _accountTransactionService.AddAccountPaymentTransaction(newAccount.CustomerAccountId, AccountTransactionType.OneOff, -newAccount.TotalOneOffItems);
             }
             _accountService.CommitChanges();
         }))
         {
             return(RedirectToAction("Edit", "Customer",
                                     new
             {
                 id = newAccount.CustomerId,
                 moveOnToEditAccount = newAccount.CustomerAccountId
             }));
         }
     }
     return(View(mAcceptAccountVm));
 }