public async Task <IActionResult> Delete(int productId) { try { var product = await _repo.GetProductAsyncByIdAsync(productId, false); if (product == null) { return(NotFound()); } _repo.Delete(product); if (await _repo.SaveChangesAsync()) { return(Ok()); } } catch (System.Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Banco Dados Falhou")); } return(BadRequest()); }
public ActionResult confirmDelProd(int id) { var product = _ProductRepository.Get(id); if (product == null) { return(HttpNotFound()); } _ProductRepository.Delete(product); return(null); }
public async Task <ServiceResponse> Delete(int idProduct) { var sr = new ServiceResponse(); try { sr.Data = await _repositoryProduct.Delete(idProduct); } catch (Exception ex) { sr.AddError(ex); } return(sr); }
public async Task <IActionResult> DeleteProduct(int productCode) { try { var productCod = await _efCoreRepositoryProduct.Delete(productCode); if (productCod == null) { return(NotFound()); } return(Ok(productCod)); } catch (Exception) { return(BadRequest()); } }
public IActionResult Delete(int id) { if (id == 0) { return(BadRequest("Parâmetro nullo")); } try { _repository.Delete(id); _repository.Save(); } catch (Exception e) { return(BadRequest(e.Message)); } return(Ok("Produto delatado com sucesso")); }