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 bool CanBeDeleted()
 {
     return(ProductSells.All(x => !x.IsStillActive()));
 }
Beispiel #3
0
 public void AddProductSell(ProductSell productSell)
 {
     //each combination in product sell has to be asserted that it contains all changeable attributes
     ProductSells.Add(productSell);
 }
Beispiel #4
0
 public void AddProductSell(ProductSells sells)
 {
     context.ProductSells.Add(sells);
     context.SaveChanges();
 }