コード例 #1
0
        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,
                });
            }
        }
コード例 #2
0
        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" }));
        }