コード例 #1
0
        public async Task <ActionResult> UpdateAsync(Guid id, ConferenceDetailsDto dto)
        {
            dto.Id = id;
            await _conferenceService.UpdateAsync(dto);

            return(NoContent());
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        public async Task <ActionResult> AddAsync(ConferenceDetailsDto dto)
        {
            await _conferenceService.AddAsync(dto);

            AddResourceIdHeader(dto.Id);
            return(CreatedAtAction(nameof(Get), new { id = dto.Id }, null));
        }
コード例 #4
0
 private static void Map(Conference conference, ConferenceDetailsDto dto)
 {
     conference.Id          = dto.Id;
     conference.HostId      = dto.HostId;
     conference.Name        = dto.Name;
     conference.Description = dto.Description;
     conference.Location    = dto.Location;
     conference.From        = dto.From;
     conference.To          = dto.To;
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        public async Task UpdateAsync(ConferenceDetailsDto dto)
        {
            var conference = await GetConferenceAsync(dto.Id);

            var hostId = conference.HostId;

            if (conference is null)
            {
                throw new ConferenceNotFoundException(dto.Id);
            }

            Map(conference, dto);
            conference.HostId = hostId; // Host cannot be updated
            await _conferenceRepository.UpdateAsync(conference);

            _logger.LogInformation("Updated a conference: '{Name}' with ID: '{Id}'", dto.Name, dto.Id);
        }
コード例 #8
0
        public async Task UpdateAsync(ConferenceDetailsDto dto)
        {
            var conference = await _conferenceRepository.GetAsync(dto.Id);

            if (conference is null)
            {
                throw new ConferenceNotFoundException(dto.Id);
            }

            conference.Name              = dto.Name;
            conference.Description       = dto.Description;
            conference.Location          = dto.Location;
            conference.LogoUrl           = dto.LogoUrl;
            conference.From              = dto.From;
            conference.To                = dto.To;
            conference.ParticipantsLimit = dto.ParticipantsLimit;
            await _conferenceRepository.UpdateAsync(conference);
        }