public async Task <IActionResult> Delete([FromRoute] string initiaitveId) { if (String.IsNullOrEmpty(initiaitveId)) { logger.LogError("Parameter is empty"); return(new BadRequestObjectResult(new { error = "Parameters cannot be empty" })); } try { var result = await initiativeService.DeleteInitiative(new Guid(initiaitveId)); return(Ok(result)); } catch (Exception ex) { logger.LogError(ex, ex.Message); return(BadRequest($"Something went wrong!, {ex.Message}")); } }
public async Task <IActionResult> DeleteInitiative(string id) { var existingInitiative = await _initiativeService.GetInitiative(id); if (existingInitiative == null) { return(BadRequest("Initiative not exists")); } if (existingInitiative != null) { var result = await _initiativeService.DeleteInitiative(existingInitiative); if (result) { return(Ok()); } } return(BadRequest("Failed to delete Initiative")); }