public ServiceResult <bool> DeletePerson(DeletePersonVm model) { model.Validate(); var person = _repository.Person.GetById(model.PersonId.Value, true); if (person == null) { throw new DomainException("Person Not Found", ExceptionLevel.Error); } person.Delete(); var relations = _repository.PersonRelation.GetByPersonId(model.PersonId, true); for (int i = 0; i < relations.Count; i++) { relations[i].Delete(); } var relation = _repository.PersonRelation.GetByRelatedPersonId(person.Id, true); relation.Delete(); _repository.Person.Save(); return(new ServiceResult <bool> { Status = ServiceResultStatus.Success }); }
public IActionResult DeletePerson([FromBody] DeletePersonVm model) { var apiResult = Try(() => { return(_personService.DeletePerson(model)); }); return(Ok(apiResult)); }