public async Task <Result> DeleteSpecie(int id) { try { Specie entity = await _specieRepository.GetById(id); if (entity == null) { return(new Result { Success = false, ErrorCode = ErrorCode.NotFound, }); } return(await _specieRepository.Delete(entity)); } catch (Exception ex) { _logger.LogError(ex, $"Problems with deleting Specie by id : {id}"); return(new Result { Success = false, ErrorCode = ErrorCode.InternalError, }); } }
public ActionResult DeleteSpecie(int specieId) { Pet deletePetType = _PetRepo.GetBySpecie(specieId); if (deletePetType != null) { return(Json(new { Result = "Fail, cannot delete the pet specie which have a pet. Please delete all pet which belong to the specie before try again" })); } ///////// Specie deleteType = _SpecieRepo.GetById(specieId); _SpecieRepo.Delete(deleteType); return(Json(new { Result = "Success" })); }