public async Task <Result> Handle(DeleteIndividualCommand request, CancellationToken cancellationToken)
        {
            var individual = await _individualsRepository.FindSingle(request.Id.Value);

            if (individual == null)
            {
                return(Result.NotFound("Couldn't find resource with provided identifier"));
            }

            await _individualsRepository.Delete(request.Id.Value);

            return(Result.OK(ResultType.NoContent));
        }
Example #2
0
        public async Task <IActionResult> Delete(int id)
        {
            var existing = await _repository.GetIndividualAsync(id);

            if (existing == null)
            {
                return(NotFound(_localizer["Individual Could not be found"]));
            }

            _repository.Delete(existing);

            if (await _repository.SaveChangesAsync())
            {
                return(Ok());
            }

            return(BadRequest());
        }
        public async Task <IActionResult> DeleteRelative(int id, int relativeId, int relationType)
        {
            var relation = await _repository.GetRelationByRelativeId(id, relativeId, relationType);

            if (relation == null)
            {
                return(NotFound("Such a relation does not exist"));
            }

            _repository.Delete(relation);

            if (await _repository.SaveChangesAsync())
            {
                return(Ok());
            }

            return(BadRequest());
        }