Ejemplo n.º 1
0
        public async Task DeleteAsync(Guid id)
        {
            var conference = await _conferenceRepository.GetAsync(id);

            if (conference is null)
            {
                throw new ConferenceNotFoundException(id);
            }

            if (await _conferenceDeletionPolicy.CanDeleteAsync(conference) is false)
            {
                throw new CannotDeleteHConferenceException(id);
            }

            await _conferenceRepository.DeleteAsync(conference);
        }
Ejemplo n.º 2
0
        public async Task <bool> CanDeleteAsync(Host host)
        {
            if (host.Conferences is null || !host.Conferences.Any())
            {
                return(true);
            }

            foreach (var conference in host.Conferences)
            {
                if (await _conferenceDeletionPolicy.CanDeleteAsync(conference) is false)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        public async Task DeleteAsync(Guid id)
        {
            var conference = await _conferenceRepository.GetAsync(id);

            if (conference is null)
            {
                throw new ConferenceNotFoundException(id);
            }

            if (!await _conferenceDeletionPolicy.CanDeleteAsync(conference))
            {
                throw new CannotDeleteConferenceException(id);
            }

            _conferenceRepository.Delete(conference);
            await _conferenceRepository.UnitOfWork.SaveChangesAsync();
        }