Beispiel #1
0
        public ActionResult Sell(ProductSellVM sellVM)
        {
            if (ModelState.IsValid)
            {
                var product = context.GetElement(sellVM.ProdcutID.Value);
                if (product != null)
                {
                    if (product.ProductAmount >= sellVM.ProductAmount)
                    {
                        ProductSells sells = new ProductSells();
                        sells.ProdcutID     = sellVM.ProdcutID;
                        sells.PrioductName  = sellVM.PrioductName;
                        sells.Price         = sellVM.Price;
                        sells.Notes         = sellVM.Notes;
                        sells.dateSell      = sellVM.dateSell;
                        sells.ProductAmount = sellVM.ProductAmount;
                        context.AddProductSell(sells);

                        product.ProductAmount -= sellVM.ProductAmount;
                        context.Updata(product);
                        context.Savechange();
                        return(RedirectToAction(nameof(Index), new { manhalID = product.ManhalId }));
                    }
                }
            }
            return(View(sellVM));
        }
Beispiel #2
0
        public ActionResult Sell(int id)
        {
            ProductSellVM sells = new ProductSellVM();

            sells.ProdcutID    = id;
            sells.PrioductName = context.GetElement(id).ProductName;
            sells.dateSell     = DateTime.Now;
            return(View(sells));
        }
 public void SellProducts([FromBody] ProductSellVM productSellVM)
 {
     UnitOfWork.SellRepository.Add((Sell)productSellVM);
 }