public ActionResult Add(string id) { try { var product = new Product { Name = id, CreatedBy = "adamstephensen", LastModifiedBy = "adamstephensen", }; _productRepository.Add(product); _unitOfWork.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException deve) { IEnumerable<DbValidationError> errors = deve.EntityValidationErrors.SelectMany(c => c.ValidationErrors); var message = string.Join(",",errors.Select(c => c.ErrorMessage)); return Content(message); } catch (Exception ex) { return Content(ex.ToString()); } return RedirectToAction("Index"); }
public ActionResult Create() { using (_unitOfWork) { var order = new Order{}; _orderRepository.Add(order); var product = new Product(); _productRepository.Add(product); _unitOfWork.SaveChanges(); } return Content("it worked"); }
public ActionResult Add(string id) { try { var product = new Product { Name = id, CreatedBy = "adamstephensen", LastModifiedBy = "adamstephensen", }; _productService.Add(product); } catch (Exception ex) { return Content(ex.Message); } return RedirectToAction("Index"); }
public Product Update(Product product) { _productRepository.Update(product); _unitOfWork.SaveChanges(); return product; }
public Product Add(Product product) { _productRepository.Add(product); _unitOfWork.SaveChanges(); return product; }