public async Task <bool> DeleteSchedulerAsync(Guid id) { try { var scheduler = await _schedulerRepository.SingleOrDefault(x => x.Id == id); if (scheduler != null && scheduler.RoomSchedulers.Any()) { await _mediator.Publish(new Notification("DeleteSchedulerAsync", $"Antes de remover esta agenda, é necessário remover todas as salas")); return(false); } await _schedulerRepository.DeleteAsync(id); return(await _schedulerRepository.CommitAsync()); } catch (Exception ex) { await _mediator.Publish(new Notification("DeleteSchedulerAsync_Exception", $"Ocorreu um erro ao tentar excluir a sala solicitada.")); } return(false); }