public ActionResult FullUpdateProduct(int id, ProductUpdateDto productUpdateDto)
        {
            var productFromRepo = _repository.GetProductById(id);

            if (productFromRepo == null)
            {
                return(NotFound());
            }
            _mapper.Map(productUpdateDto, productFromRepo);
            _repository.UpdateProduct(productFromRepo);
            if (_repository.SaveChanges())
            {
                return(NoContent());
            }
            return(BadRequest());
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Update([FromBody] Product p)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Səhv özəlliklər daxil edilib."));
            }

            var result = await _repo.UpdateProduct(p);

            if (result.IsSucces)
            {
                return(Ok(result.Content));
            }

            return(StatusCode(520, result.Message));
        }
Ejemplo n.º 3
0
 public IActionResult Update(int id, UpdateBikeViewModel model)
 {
     if (ModelState.IsValid)
     {
         string photoPath = String.Empty;
         if (model.ProductPhoto == null)
         {
             photoPath = model.ExistingPhoto;
         }
         else
         {
             photoPath = GetPhotoPath(model);
         }
         var bike = _mapper.Map <Product>(model);
         bike.ProductPhoto = photoPath;
         _productsRepo.UpdateProduct(bike);
         return(RedirectToAction("Details", new { id = bike.ProductId }));
     }
     ViewBag.Brands     = new SelectList(_brandsRepo.GetBrands(), "BrandName", "BrandName");
     ViewBag.Categories = new SelectList(_categoriesRepo.GetCategories(), "CategoryName", "CategoryName");
     return(View(model));
 }