public async Task <IActionResult> DeleteBank(Guid id) { var bankExists = _bankService.ExistsAsync(id); if (!(await bankExists)) { return(NotFound()); } await _bankService.DeleteAsync(id); return(NoContent()); }
public async Task<ActionResult> DeleteAsync(int id) { if (!ModelState.IsValid || id < 1) return BadRequest(); try { var exist = await service.GetByIdAsync(id); if (exist != null) { var result = await service.DeleteAsync(id); return result ? Ok(new Response { Status = true, Description = "Record deleted successfully" }) : StatusCode(500, new Response { Status = false, Description = "Error deleting the record" }); } else { return NotFound(); } } catch (Exception ex) { logger.LogError(ex.Message); return StatusCode(500, new Response() { Status = false, Description = "System error" }); } }