Esempio n. 1
0
        public async Task <bool> Delete(int id)
        {
            var person = _personRepository
                         .GetAll()
                         .Include(e => e.PersonEvents)
                         .ThenInclude(pe => pe.Person)
                         .FirstOrDefault(p => p.Id == id);

            var relationships = _relationshipRepository
                                .GetAll()
                                .Where(r => r.PersonId == id || r.RelatedPersonId == id);

            _relationshipRepository.RemoveRange(relationships);
            _personRepository.Remove(person);

            return(await _personRepository.SaveChangesAsync());
        }