コード例 #1
0
        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,
                });
            }
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        public ActionResult <Family> DeleteFamily(int id)
        {
            var family = _familyRepository.GetById(id);

            if (family == null)
            {
                return(NotFound());
            }

            _familyRepository.Delete(family);
            _familyRepository.Save();

            return(family);
        }
コード例 #4
0
 public void DeleteForm(string keyValue)
 {
     service.Delete(t => t.F_Id == keyValue);
 }
コード例 #5
0
 public void DeleteFamily(Family Family)
 {
     _repository.Delete(Family);
 }