Пример #1
0
        public ActionResult Inward(Guid storeItemsId)
        {
            StoreItems          storeItems = _dbContext.StoreItems.Find(storeItemsId);
            IssueItems          issueItems = new IssueItems();
            IssueItemsViewModel viewModel  = Mapper.Map <IssueItemsViewModel>(issueItems);

            ViewBag.IssueType       = new SelectList(viewModel.getIssueTypeList(), "Value", "Text", "2");
            ViewBag.ItemName        = storeItems.Name;
            viewModel.StoreItemsId  = storeItemsId;
            viewModel.RemainingItem = storeItems.BalanceQuantity;
            return(PartialView("_Inward", viewModel));
        }
Пример #2
0
        public ActionResult Inward([Bind(Include = "Id,IssueInvoice,IssueDate,DepartmentName,EmployeeName,Remark,InwardQuantity,RemainingItem,StoreItemsId,IssueType")] IssueItemsViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                IssueItems issueItems = Mapper.Map <IssueItems>(viewModel);
                issueItems.IssueType = "Return";
                StoreItems storeItems    = _dbContext.StoreItems.Find(issueItems.StoreItemsId);
                decimal?   remaningItems = storeItems.BalanceQuantity + issueItems.InwardQuantity;
                issueItems.RemainingItem = remaningItems;
                issueItems.Id            = Guid.NewGuid();

                // updating store items balance items
                storeItems.BalanceQuantity         = remaningItems;
                _dbContext.Entry(storeItems).State = EntityState.Modified;

                _dbContext.IssueItems.Add(issueItems);
                _dbContext.SaveChanges();
                return(Json(new { success = true }));
            }

            ViewBag.IssueType = new SelectList(viewModel.getIssueTypeList(), "Value", "Text", "1");
            return(View(viewModel));
        }