public ActionResult Create(Product products) { if (ModelState.IsValid) { this.productRepository.Create(products); return RedirectToAction("Index"); } ViewBag.CategoryID = new SelectList(this.Categories, "CategoryID", "CategoryName", products.CategoryID); return View(products); }
public ActionResult Create(Product products, string category) { if (ModelState.IsValid) { this.productService.Create(products); return RedirectToAction("Index", new { category = category }); } ViewBag.CategoryID = new SelectList(this.Categories, "CategoryID", "CategoryName", products.CategoryID); return View(products); }
public IResult Update(Product instance) { if (instance == null) { throw new ArgumentNullException(); } IResult result = new Result(false); try { this.repository.Update(instance); result.Success = true; } catch (Exception ex) { result.Exception = ex; } return result; }
public IResult Create(Product instance) { if (instance == null) { throw new ArgumentNullException(); } IResult result = new Result(false); try { this._repository.Create(instance); this._unitOfWork.SaveChange(); result.Success = true; } catch (Exception ex) { result.Exception = ex; } return result; }
public ActionResult Create(Product products, string category) { if (ModelState.IsValid) { using (var unitOfwork = this._unitOfWorkFactory.Create()) { this._productService.Create(products); unitOfwork.SaveChange(); } return RedirectToAction("Index", new { category = category }); } ViewBag.CategoryID = new SelectList(this.Categories, "CategoryID", "CategoryName", products.CategoryID); return View(products); }