public ActionResult UpdateLocalStock(LokaalVoorraad Pmodel) { if (!ModelState.IsValid) { return(View(Pmodel)); } // check the localStock, d.UpdateLocalStock(Pmodel); return(RedirectToAction("Producten", "Home")); }
//Stock store update en totalstock update public void UpdateLocalStock(LokaalVoorraad model) { var entity = entities.prod_vest_voorraad.Single(st => st.vestiging_id == model.vestigingID && st.product_id == model.ProductID); int x = entity.voorraad_vest.HasValue ? entity.voorraad_vest.Value : 0; entity.voorraad_vest = model.StoreStock; var difference = entity.voorraad_vest - x; entity.distributie_product.totalLocal = entity.distributie_product.totalLocal + difference; entities.SaveChanges(); }