public IActionResult DeleteProduct(int id) { if (id <= 0) { return(NotFound()); } _productRepo.DeleteProduct(id); _productRepo.CommitChanges(); return(Ok()); }
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); } }
public ActionResult <string> Delete(int id) { if (id != 0) { if (_repository.DeleteProduct(id)) { return(Ok("Deleted")); } } return(NotFound("Not Found")); }
public bool RemoveProduct(int id) { if (id <= 0) { throw new Exception("Minimum ID is 1."); } else { return(_productRepo.DeleteProduct(id)); } }
public ActionResult DeleteProduct(int id) { var productInDb = _repository.GetProductById(id); if (productInDb == null) { return(NotFound()); } _repository.DeleteProduct(productInDb); _repository.SaveChanges(); return(NoContent()); }
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")); }
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.")); } }
public IActionResult Delete(long id) { repo.DeleteProduct(id); return(RedirectToAction(nameof(Index))); }
public void DeleteProduct(Product product) { repo.DeleteProduct(product); }
public async Task <IActionResult> DeleteProduct(int productId) { var data = await _repo.DeleteProduct(productId); return(Ok(data)); }
public void Delete(int id) { var productToDelete = _repo.GetProduct(id); _repo.DeleteProduct(productToDelete); }
public IActionResult DeleteProduct(Product product) { repo.DeleteProduct(product); return(RedirectToAction("Index")); }
public Product RemoveProduct(int id) { return(_productRepo.DeleteProduct(id)); }
public Task <bool> Handle(DeleteProductCommand request, CancellationToken cancellationToken) { return(Task.FromResult(_repository.DeleteProduct(request.Id))); }