public async Task <HostDetailsDto> GetAsync(Guid id) { var host = await _hostRepository.GetAsync(id); if (host is null) { return(null); } var dto = Map <HostDetailsDto>(host); dto.Conferences = host.Conferences?.Select(x => new ConferenceDto { Id = x.Id, HostId = x.HostId, HostName = x.Host.Name, From = x.From, To = x.To, Name = x.Name, Location = x.Location, LogoUrl = x.LogoUrl, ParticipantsLimit = x.ParticipantsLimit }).ToList() ?? new List <ConferenceDto>(); return(dto); }
public async Task <HostDetailsDto> GetAsync(Guid id) { var host = await _hostRepository.GetAsync(id); if (host is null) { return(null); } var dto = Map <HostDetailsDto>(host); if (dto.Conferences is not null) { dto.Conferences = host.Conferences.Select(x => new ConferenceDto() { Id = x.Id, HostId = x.HostId, Name = x.Name, From = x.From, To = x.To, Location = x.Location, Description = x.Description, LogoUrl = x.LogoUrl, Host = x.Host, ParticipantLimit = x.ParticipantLimit }).ToList(); } else { dto.Conferences = new (); } return(dto); }
public async Task UpdateAsync(HostDetailsDto dto) { var host = await _hostRepository.GetAsync(dto.Id); if (host is null) { throw new HostNotFoundException(dto.Id); } host.Name = dto.Name; host.Description = dto.Description; await _hostRepository.UpdateAsync(host); }
public async Task AddAsync(ConferenceDetailsDto dto) { if (await _hostRepository.GetAsync(dto.HostId) is null) { throw new HostNotFoundException(dto.Id); } dto.Id = Guid.NewGuid(); var conference = new Conference() { Id = dto.Id, HostId = dto.HostId, Name = dto.Name, Description = dto.Description, From = dto.From, To = dto.To, Location = dto.Location, LogoUrl = dto.LogoUrl, ParticipantLimit = dto.ParticipantLimit }; await _conferenceRepository.AddAsync(conference); await _messageBroker.PublishAsync(new ConferenceCreated(conference.Id, conference.Name, conference.ParticipantLimit, conference.From, conference.To)); }
private async Task ValidateHostExistsAsync(Guid hostId) { var host = await _hostRepository.GetAsync(hostId); if (host is null) { throw new HostNotFoundException(hostId); } }
private async Task ReloadTenantsToCache() { Cache.Remove("tenants"); await Cache.GetOrCreateAsync("tenants", async t => { t.SetSlidingExpiration(TimeSpan.FromMinutes(30)); var list = await _hostRepository.GetAsync <Tenant>(t => t.ResourcesCreated); return(list.ToList()); }); }
private async Task LoadTenantsFromDatabase() { var tenants = await _memoryCahce.GetOrCreateAsync("tenants", async t => { t.SetSlidingExpiration(TimeSpan.FromMinutes(30)); var tenantList = await _hostRepository.GetAsync <Tenant>(t => t.ResourcesCreated, includeProperties: "TenantSetting"); return(tenantList.ToList()); }); _tenants = tenants.ToList(); }