예제 #1
0
        public ActionResult SavePurchaseInvoice(AmountModel model)
        {
            try
            {
                var products = Session["productlist"] as List <DATA.Domains.PurchaseItem>;

                var UserInfo = (Dashboard.Models.UserInfo)Session["UserInfo"];

                var purchase = productprovider.GeneratePurchase();

                products.ForEach(x => x.PurchaseId = purchase.Id);
                products.ForEach(x => x.CreatedOn  = DateTime.Now);

                productprovider.SavePurchaseItems(products);

                var ledgerForBuyer = BuildLedger(purchase.Id, model.InsertionTypeId, UserInfo.UserId, model.AmountIn, model.AmountOut, model.Balance, model.Total, model.AccountHolderId);
                ledgerProvider.SaveLedger(ledgerForBuyer);

                var trademarkaccountholder = productprovider.gettrademarakaccountholder(UserInfo.TrademarkID);

                var ledgerFortradeMark = BuildLedger(purchase.Id, model.InsertionTypeId, UserInfo.UserId, model.AmountOut, model.AmountIn, -model.Balance, model.Total, trademarkaccountholder.Id);
                ledgerProvider.SaveLedger(ledgerFortradeMark);

                var Buyerledger = ledgerProvider.GetLedgerByPurchaseId(purchase.Id);
                TempData["ledger"] = Buyerledger;

                Session["productlist"] = null;

                return(RedirectToAction("ShowPurchaseInvoice"));
            }
            catch (Exception ex)
            {
                return(View("Views/Product/Error.cshtml", ex.Message));
            }
        }