public IActionResult GetAccommodations(int groupId, int subgroupId, int attendeeId)
        {
            var userIdentifier = _registrationAuthorizationService.GetCurrentUserIdentifier(User);

            if (userIdentifier == null)
            {
                return(BadRequest());
            }

            if (!_registrationAuthorizationService.IsAuthorized(userIdentifier, subgroupId))
            {
                return(Unauthorized());
            }

            var attendeeEntity = _registrationRepository.GetAttendee(subgroupId, attendeeId);

            if (attendeeEntity == null)
            {
                return(NotFound());
            }

            var accommodationDto = new List <AccommodationDto>();

            foreach (var attendeeAccommodation in attendeeEntity.AttendeeAccommodations)
            {
                var accommodation = _registrationRepository.GetAccommodations().FirstOrDefault(a => a.Id == attendeeAccommodation.AccommodationId);
                accommodationDto.Add(Mapper.Map <AccommodationDto>(accommodation));
            }

            return(Ok(accommodationDto));
        }
Beispiel #2
0
        public IActionResult GetAllAccommodations()
        {
            var accommodationEntities = _registrationRepository.GetAccommodations();
            var accommodationDtos     = Mapper.Map <IEnumerable <AccommodationDto> >(accommodationEntities);

            return(Ok(accommodationDtos));
        }