Пример #1
0
        public ActionResult Edit(Product p)
        {
            if (ModelState.IsValid)
            {
                repository.Save(p);

                return RedirectToAction("List");
            }

            ViewBag.Message = "Unexpected error!";

            return View();
        }
Пример #2
0
        public void Add(Product product)
        {
            EFProductRepository repo = new EFProductRepository();

            if (product == null)
                throw new HttpResponseException(System.Net.HttpStatusCode.BadRequest);

            try
            {
                repo.Save(product);
            }
            catch
            {
                throw;
            }
            finally
            {
                repo = null;
            }
        }
Пример #3
0
        public ActionResult New(Product p)
        {
            if (ModelState.IsValid)
            {
                p = repository.Save(p);
                ViewBag.Message = "Product added successfully!";
                return RedirectToAction("List");
            }

            return View(p);
        }