Ejemplo n.º 1
0
 public ActionResult Create(Product product)
 {
     if (ModelState.IsValid) {
         _productService.InsertOrUpdate(product);
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
Ejemplo n.º 2
0
        public void InsertOrUpdate(Product product)
        {
            if (product.ProductId == default(int))
            {
                // New entity
                _context.Products.Add(product);
            }
            else
            {
                // Existing entity
                if (_context.Products.Any(x => x.ProductId != product.ProductId))
                {
                    throw new ObjectNotFoundException(Business.Domain.Resources.Errors.Product_Update_EntityNotFound);
                }

                _context.Entry(product).State = EntityState.Modified;
            }
        }
Ejemplo n.º 3
0
 public void InsertOrUpdate(Product product)
 {
     _productRepository.InsertOrUpdate(product);
     _productRepository.Save();
 }