Пример #1
0
 public IActionResult DeleteProduct(int id)
 {
     if (id <= 0)
     {
         return(NotFound());
     }
     _productRepo.DeleteProduct(id);
     _productRepo.CommitChanges();
     return(Ok());
 }
Пример #2
0
        public ActionResult Delete(int productId)
        {
            Product deletedP = repository.DeleteProduct(productId);

            if (deletedP != null)
            {
                TempData["message"] = $"{deletedP.Name}已经被删除!";
            }
            return(RedirectToAction("Index"));
        }
 //To Delete the record on a particular Product
 public async Task DeleteProduct(int?id)
 {
     try
     {
         await _iProductRepo.DeleteProduct(id);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Пример #4
0
 public ActionResult <string> Delete(int id)
 {
     if (id != 0)
     {
         if (_repository.DeleteProduct(id))
         {
             return(Ok("Deleted"));
         }
     }
     return(NotFound("Not Found"));
 }
Пример #5
0
 public bool RemoveProduct(int id)
 {
     if (id <= 0)
     {
         throw new Exception("Minimum ID is 1.");
     }
     else
     {
         return(_productRepo.DeleteProduct(id));
     }
 }
Пример #6
0
        public ActionResult DeleteProduct(int id)
        {
            var productInDb = _repository.GetProductById(id);

            if (productInDb == null)
            {
                return(NotFound());
            }
            _repository.DeleteProduct(productInDb);
            _repository.SaveChanges();
            return(NoContent());
        }
Пример #7
0
        public async Task <IActionResult> DeleteProduct(string id)
        {
            if (await _repo.GetProduct(id) == null)
            {
                return(NotFound());
            }
            var response = await _repo.DeleteProduct(id);

            if (!response)
            {
                return(BadRequest("Something went wrong"));
            }
            return(Ok("Product removed successfully"));
        }
Пример #8
0
        public IActionResult Delete(int id)
        {
            Product product = null;

            product = _productRepo.DeleteProduct(id);

            if (product != null)
            {
                return(Ok(product));
            }
            else
            {
                return(NotFound("Product with Id = " + id.ToString() + " not found to Delete."));
            }
        }
Пример #9
0
 public IActionResult Delete(long id)
 {
     repo.DeleteProduct(id);
     return(RedirectToAction(nameof(Index)));
 }
 public void DeleteProduct(Product product)
 {
     repo.DeleteProduct(product);
 }
Пример #11
0
        public async Task <IActionResult> DeleteProduct(int productId)
        {
            var data = await _repo.DeleteProduct(productId);

            return(Ok(data));
        }
Пример #12
0
        public void Delete(int id)
        {
            var productToDelete = _repo.GetProduct(id);

            _repo.DeleteProduct(productToDelete);
        }
Пример #13
0
        public IActionResult DeleteProduct(Product product)
        {
            repo.DeleteProduct(product);

            return(RedirectToAction("Index"));
        }
 public Product RemoveProduct(int id)
 {
     return(_productRepo.DeleteProduct(id));
 }
Пример #15
0
 public Task <bool> Handle(DeleteProductCommand request, CancellationToken cancellationToken)
 {
     return(Task.FromResult(_repository.DeleteProduct(request.Id)));
 }