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)); }
public async Task AddAsync(ConferenceDetailsDto dto) { await ValidateHostExistsAsync(dto.HostId); dto.Id = Guid.NewGuid(); var conference = new Conference(); Map(conference, dto); await _conferenceRepository.AddAsync(conference); _logger.LogInformation("Created a conference: '{Name}' with ID: '{Id}'", dto.Name, dto.Id); }
public async Task <IActionResult> Create([Bind("LongName,ShortName,FirstSeasonYear,LastSeasonYear")] Conference conference) { if (ModelState.IsValid) { await _conferenceRepository.AddAsync(conference); await _sharedRepository.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(conference)); }
public async Task HandleAsync(ConferenceCreated @event) { var conference = new Conference { Id = @event.Id, Name = @event.Name, ParticipantsLimit = @event.ParticipantsLimit, From = @event.From, To = @event.To }; await _conferenceRepository.AddAsync(conference); _logger.LogInformation($"Added a conference with ID: '{@event.Id}'."); }
public async Task AddAsync(ConferenceDetailsDto dto) { await ValidateHostExistsAsync(dto.HostId); dto.Id = Guid.NewGuid(); var conference = new Conference(); Map(conference, dto); await _conferenceRepository.AddAsync(conference); await _messageBroker.PublishAsync(new ConferenceCreated(conference.Id, conference.Name, conference.ParticipantsLimit)); _logger.LogInformation("Created a conference: '{Name}' with ID: '{Id}'", dto.Name, dto.Id); }