public IHttpActionResult Delete(SaleViewModel model) { if (!ModelState.IsValid) { BadRequest(); } else { _serviceSale.DeleteSale(model.SaleId); return(Ok()); } return(Ok()); }
public async Task <IActionResult> Delete(int id, SaleViewModel model) { try { await _saleService.DeleteSale(id); return(RedirectToAction(nameof(Index))); } catch { ViewData["Id"] = id; return(View()); } }
public JsonResult Delete(SaleViewModel saleViewModel) { bool isSuccess; string exceptionMessage = string.Empty; try { _saleService.DeleteSale(saleViewModel); isSuccess = true; } catch (Exception exception) { exceptionMessage = exception.Message; isSuccess = false; } return(Json(new { isSuccess = isSuccess, exceptionMessage = exceptionMessage })); }
public async Task <IActionResult> Delete([FromRoute] int id) { var sale = await _saleService.SearchSale(id); // check out if exists and get object Entity if (sale == null) { return(NotFound()); } try { await _saleService.DeleteSale(sale); } catch (DbUpdateException ex) { Console.WriteLine(ex); return(BadRequest()); } return(Ok(sale)); }
public async Task <IActionResult> DeleteSale(Guid idSale) { await _saleService.DeleteSale(idSale); return(await ResponseAsync()); }
public void Delete(int id) { saleService.DeleteSale(id); }