Пример #1
0
        public async Task UpdateAttendStatusAsync(UpdateAttendStatusDto updateAttendStatusDto)
        {
            var @event = await _eventsDbSet
                         .Include(x => x.EventParticipants)
                         .Include(x => x.EventOptions)
                         .Include(x => x.EventType)
                         .Where(x => x.Id == updateAttendStatusDto.EventId &&
                                x.OrganizationId == updateAttendStatusDto.OrganizationId)
                         .Select(MapEventToJoinValidationDto)
                         .FirstOrDefaultAsync();

            _eventValidationService.CheckIfEventExists(@event);

            // ReSharper disable once PossibleNullReferenceException
            _eventValidationService.CheckIfRegistrationDeadlineIsExpired(@event.RegistrationDeadline);

            _eventValidationService.CheckIfAttendStatusIsValid(updateAttendStatusDto.AttendStatus);
            _eventValidationService.CheckIfAttendOptionIsAllowed(updateAttendStatusDto.AttendStatus, @event);

            await AddParticipantWithStatusAsync(updateAttendStatusDto.UserId, updateAttendStatusDto.AttendStatus, updateAttendStatusDto.AttendComment, @event);

            await _uow.SaveChangesAsync(false);
        }