Ejemplo n.º 1
0
        public ActionResult Create(PurchaseReceivingCreateVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    foreach (PurchaseReceivingDetails purchaseReceivingDetails in model.PurchaseReceivingDetailses)
                    {
                        var Stock = _stockManager.GetFirstOrDefault();
                        //Stock.AvgPrice = (Stock.StockQuantity * Stock.AvgPrice + purchaseReceivingDetails.Quantity * purchaseReceivingDetails.PurchasePrice) / (Stock.StockQuantity + purchaseReceivingDetails.Quantity);
                        //Stock.StockQuantity = Stock.StockQuantity + purchaseReceivingDetails.Quantity;
                        //Stock.ItemId = purchaseReceivingDetails.ItemId;
                    }

                    //var MappedStock = Mapper.Map<Stock>(Stock);
                    //bool StockIsSaved = _stockManager.Save(MappedStock);
                    var  purchaseReceiving = Mapper.Map <PurchaseReceiving>(model);
                    bool isSaved           = _purchaseReceivingManager.Save(purchaseReceiving);
                    if (isSaved)
                    {
                        return(RedirectToAction("Create"));
                    }
                }
            }
            catch (Exception exception)
            {
                ModelState.AddModelError("", exception.Message);


                var itemList = _itemManager.GetAll();
                model.Items = itemList;
                var branchList = _branchManager.GetAll();
                model.Branches = branchList;
                var employeeInfoList = _employeeInfoManager.GetAll();
                model.EmployeeInfoes = employeeInfoList;
                return(View(model));
            }

            var item = _itemManager.GetAll();

            model.Items = item;
            var branch = _branchManager.GetAll();

            model.Branches = branch;
            var employeeInfo = _employeeInfoManager.GetAll();

            model.EmployeeInfoes = employeeInfo;
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Create(PurchaseReceivingCreateVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _stockManager.UpdateStockWithPurchaseReceiving(model.PurchaseReceivingDetailses, model.BranchId);
                    var  purchaseReceiving = Mapper.Map <PurchaseReceiving>(model);
                    bool isSaved           = _purchaseReceivingManager.Save(purchaseReceiving);
                    if (isSaved)
                    {
                        return(RedirectToAction("Create"));
                    }
                }
            }
            catch (Exception exception)
            {
                ModelState.AddModelError("", exception.Message);


                var itemList = _itemManager.GetAll();
                model.Items = itemList;
                var branchList = _branchManager.GetAll();
                model.Branches = branchList;
                var employeeInfoList = _employeeInfoManager.GetAll();
                model.EmployeeInfoes = employeeInfoList;
                model.Parties        = _partyManager.Get(c => c.PartyType == "Supplier");
                return(View(model));
            }

            var item = _itemManager.GetAll();

            model.Items = item;
            var branch = _branchManager.GetAll();

            model.Branches = branch;
            var employeeInfo = _employeeInfoManager.GetAll();

            model.EmployeeInfoes = employeeInfo;
            model.Parties        = _partyManager.Get(c => c.PartyType == "Supplier");
            return(View(model));
        }
Ejemplo n.º 3
0
        // GET: PurchaseReceiving/Create
        public ActionResult Create()
        {
            var model = new PurchaseReceivingCreateVM();
            var item  = _itemManager.GetAll();

            model.Items = item;
            var branch = _branchManager.GetAll();

            model.Branches = branch;
            var employeeInfo = _employeeInfoManager.GetAll();

            model.EmployeeInfoes = employeeInfo;

            ViewBag.EmployeeInfoId = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Value = "", Text = "Select"
                }
            };

            return(View(model));
        }