public async Task <Result> DeleteFamily(int id) { try { Family entity = await _familyRepository.GetById(id); if (entity == null) { return(new Result { Success = false, ErrorCode = ErrorCode.NotFound, }); } return(await _familyRepository.Delete(entity)); } catch (Exception ex) { _logger.LogError(ex, $"Problems with deleting Family by id : {id}"); return(new Result { Success = false, ErrorCode = ErrorCode.InternalError, }); } }
public async Task <ActionResult <FamilyDTO> > DeleteFamily(int familyId) { try { var familyToDelete = await _familyRepository.GetFamilyById(familyId); if (familyToDelete == null) { return(NotFound($"Family with ID: {familyId} could not be found.")); } _familyRepository.Delete(familyToDelete); if (await _familyRepository.Save()) { return(NoContent()); } } catch (TimeoutException e) { return(this.StatusCode(StatusCodes.Status408RequestTimeout, $"Request timeout: {e.Message}")); } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database Failure: {e.Message}")); } return(BadRequest()); }
public ActionResult <Family> DeleteFamily(int id) { var family = _familyRepository.GetById(id); if (family == null) { return(NotFound()); } _familyRepository.Delete(family); _familyRepository.Save(); return(family); }
public void DeleteForm(string keyValue) { service.Delete(t => t.F_Id == keyValue); }
public void DeleteFamily(Family Family) { _repository.Delete(Family); }