public IActionResult Delete(int id) { try { MyModel singleById = _exampleRepository.GetSingle(id); if (singleById == null) { return(NotFound()); } _exampleRepository.Delete(singleById); int save = _exampleRepository.Save(); if (save > 0) { return(NoContent()); } return(BadRequest()); } catch (Exception exception) { //Do something with the exception return(StatusCode((int)HttpStatusCode.InternalServerError)); } }
public bool DeleteExampleModel(int id) { try { _repository.Delete(id); _repository.SaveChanges(); } catch { return(false); } return(true); }
public int Delete(long Id) { _logger.LogDebug("Delete"); var entityToDelete = Get(Id); if (entityToDelete == null) { _logger.LogWarning("Invalid ID"); return(0); } var result = _repository.Delete(Id); _logger.LogDebug($"Delete: entity with id({Id}) deleted"); return(result); }
public async Task <bool> Delete(long id) { return(await _exampleRepository.Delete(id)); }
/// <summary> /// Delete /// </summary> /// <param name="id">The id of a record.</param> /// <returns>True if the record was deleted, false otherwise.</returns> public bool Delete(string id) { var myData = repository.Delete(id); return(myData); }