Ejemplo n.º 1
0
 public IActionResult Post([FromBody] ProductEditModel model)
 {
     if (ModelState.IsValid)
     {
         var response = _ProductRepository.Create(model.ToEntity());
         if (response.ResponseCode == ResponseCode.SUCCESSFUL)
         {
             return(Successful(ResponseMessage.SUCCESSFUL));
         }
         if (response.Errors.Count > 0)
         {
             return(Errors(response.Errors));
         }
     }
     return(Errors(ModelState));
 }
Ejemplo n.º 2
0
        public ActionResult Edit(ProductEditModel product)
        {
            Product currentProduct = productRepository.Find(product.Id);

            if (currentProduct == null)
            {
                return(RedirectToAction("index", "error", new { statusCode = 404 }));
            }

            var entity = product.ToEntity(currentProduct).MarkAsEdited();

            productRepository.Update(entity);
            using (UnitOfWork)
            {
                UnitOfWork.Commit();
            }

            return(RedirectToAction("details", new { category = currentProduct.CategoryName, name = currentProduct.Name }));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(ProductEditModel product)
        {
            Product currentProduct = productRepository.Find(product.Id);
            if (currentProduct == null)
            {
                return RedirectToAction("index", "error", new { statusCode = 404 });
            }

            var entity = product.ToEntity(currentProduct).MarkAsEdited();
            productRepository.Update(entity);
            using (UnitOfWork)
            {
                UnitOfWork.Commit();
            }

            return RedirectToAction("details", new { category = currentProduct.CategoryName, name = currentProduct.Name });
        }