Exemplo n.º 1
0
 public void SaveReservedProduct(ReservedProduct reservedProduct)
 {
     if (reservedProduct.reservID == 0)
     {
         _db.ReservedProducts.Add(reservedProduct);
     }
     else
     {
         var dbEntry = _db.ReservedProducts.Find(reservedProduct.reservID);
         if (dbEntry != null)
         {
             dbEntry.userID = reservedProduct.userID;
             dbEntry.date = reservedProduct.date;
             dbEntry.orderID = reservedProduct.orderID;
             dbEntry.productID = reservedProduct.productID;
             dbEntry.amountOfProduct = reservedProduct.amountOfProduct;
         }
     }
     _db.SaveChanges();
 }
Exemplo n.º 2
0
        public ActionResult EditReservedProduct(ReservedProduct reservedProduct)
        {
            if (ModelState.IsValid)
            {
                repository.SaveReservedProduct(reservedProduct);
                TempData["message"] = string.Format("Зарезервований товар {0} було збережено!", reservedProduct.reservID);

                return RedirectToAction("ReservedProductsList");
            }
            else
            {
                return View(reservedProduct);
            }
        }