public ActionResult AddPreOrder( ProductToBuy preOrder)
 {
     preOrder.userID = Convert.ToInt32(System.Web.HttpContext.Current.User.Identity.Name);
     preOrder.approved = false;
     preOrder.description = "";
     repository.SaveProductToBuy(preOrder);
     return RedirectToAction("CreatePreOrder");
 }
Beispiel #2
0
 public void SaveProductToBuy(ProductToBuy productToBuy)
 {
     if (productToBuy.productToBuyID == 0)
     {
         _db.ProductsToBuy.Add(productToBuy);
     }
     else
     {
         var dbEntry = _db.ProductsToBuy.Find(productToBuy.productToBuyID);
         if (dbEntry != null)
         {
             dbEntry.title = productToBuy.title;
             dbEntry.userID = productToBuy.userID;
             dbEntry.description = productToBuy.description;
             dbEntry.productCategoryID = productToBuy.productCategoryID;
             dbEntry.amount = productToBuy.amount;
             dbEntry.price = productToBuy.price;
             dbEntry.approved = productToBuy.approved;
         }
     }
     _db.SaveChanges();
 }
        public ActionResult EditProductToBuy(ProductToBuy productToBuy)
        {
            if (ModelState.IsValid)
            {
                repository.SaveProductToBuy(productToBuy);
                TempData["message"] = string.Format("Передзамовлення {0} було збережено!", productToBuy.title);

                return RedirectToAction("ProductsToBuyList");
            }
            else
            {
                return View(productToBuy);
            }
        }