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 AddRentAccountStep4(AddRentAccountVM mAddPurchaseAccountVm)
 {
     if (ModelState.IsValid)
     {
         return(RedirectToAction(Stepper2.NextStep()));
     }
     return(View(mAddPurchaseAccountVm));
 }
Ejemplo n.º 3
0
        public ActionResult AddRentAccountStep2(AddRentAccountVM mAddRentAccountVm)
        {
            var rentAcc = TempAccountAsAddRentAccountVM();

            if (rentAcc.RentedUnits == null || rentAcc.RentedUnits.Count == 0)
            {
                ModelState.AddModelError("", "No Unit has been selected!");
                return(View(mAddRentAccountVm));
            }

            rentAcc.AttachedContracts = new List <Contract>();
            rentAcc.OneOffItems.ForEach(c => c.Quantity = rentAcc.RentedUnits.Count);
            return(RedirectToAction(Stepper2.NextStep()));
        }