public async Task <IActionResult> List([FromQuery] string id)
        {
            try
            {
                var userId       = HttpContext.User.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier).Value;
                var travelPlanId = new Guid(id);
                var travelers    = await _userTravelPlanRepository.GetTravelersForActivityAsync(travelPlanId);

                if (travelers.Count() == 0)
                {
                    //travel plan doesn't exist
                    return(BadRequest(new
                    {
                        Message = "Error occurred retrieving activities for travel plan"
                    }));
                }
                if (!travelers.Contains(new Guid(userId)))
                {
                    return(Forbid());
                }

                var lstActivityDto = await _activityRepository.ListAsync(travelPlanId);

                return(Ok(lstActivityDto));
            }
            catch
            {
                return(BadRequest());
            }
        }
Example #2
0
        public async Task <List <TravelPlanActivityDto> > ListAsync(Guid travelPlanId)
        {
            try
            {
                var lstActivities = await _travelPlanActivityRepository.ListAsync(travelPlanId);

                var lstActivityDto = lstActivities.Select((a) => new TravelPlanActivityDto(a)).ToList();

                return(lstActivityDto);
            }
            catch (Exception)
            {
                throw;
            };
        }