Ejemplo n.º 1
0
        public async Task <IActionResult> GetByUrlKey(string urlKey)
        {
            var tasks = new List <Task>();

            var @event = await _eventsApi.GetByUrlKey(urlKey);

            var group = _groupsApi.GetById(@event.Result.Group.Id);

            tasks.Add(group);

            Task <ApiSuccessResponse <GetAttendeeInfoResponse> > attendeeInfo = default;

            if (User.Identity.IsAuthenticated)
            {
                attendeeInfo = _eventsApi.AttendeeInfo(@event.Result.Id);
                tasks.Add(attendeeInfo);
            }

            await Task.WhenAll(tasks);

            var response = new ApiSuccessResponse <GetEventByIdCompositionResponse>
            {
                Code   = 200,
                Result = new GetEventByIdCompositionResponse
                {
                    Event        = @event.Result,
                    Group        = group.Result.Result,
                    AttendeeInfo = User.Identity.IsAuthenticated ? attendeeInfo.Result.Result : new GetAttendeeInfoResponse()
                }
            };

            return(Ok(response));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetById(Guid id)
        {
            var tasks = new List <Task>();

            var group = _groupsApi.GetById(id);

            tasks.Add(group);

            Task <ApiSuccessResponse <GetMemberInfoResponse> > memberInfo = default;

            if (User.Identity.IsAuthenticated)
            {
                memberInfo = _groupsApi.MemberInfo(id);
                tasks.Add(memberInfo);
            }

            await Task.WhenAll(tasks);

            var response = new ApiSuccessResponse <GetGroupByIdCompositionResponse>
            {
                Code   = 200,
                Result = new GetGroupByIdCompositionResponse
                {
                    Group      = group.Result.Result,
                    MemberInfo = User.Identity.IsAuthenticated ? memberInfo.Result.Result : new GetMemberInfoResponse()
                }
            };

            return(Ok(response));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ActiveEvents(Guid id)
        {
            var activeEvents = await _eventsApi.GroupEvents(new GetGroupEventsRequest { GroupId = id, Status = "active" });

            var response = new ApiSuccessResponse <IEnumerable <GetGroupEventsResponse> >
            {
                Code   = 200,
                Result = activeEvents.Result.OrderByDescending((x) => x.Date)
            };

            return(Ok(response));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetByUrlKey(string urlKey)
        {
            var group = await _groupsApi.GetByUrlKey(urlKey);

            var memberInfoResponse = new GetMemberInfoResponse();

            if (User.Identity.IsAuthenticated)
            {
                memberInfoResponse = (await _groupsApi.MemberInfo(group.Result.Id)).Result;
            }

            var response = new ApiSuccessResponse <GetGroupByIdCompositionResponse>
            {
                Code   = 200,
                Result = new GetGroupByIdCompositionResponse
                {
                    Group      = group.Result,
                    MemberInfo = memberInfoResponse
                }
            };

            return(Ok(response));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> PastEvents(Guid id)
        {
            var completedEvents = _eventsApi.GroupEvents(new GetGroupEventsRequest {
                GroupId = id, Status = "completed"
            });
            var cancelledEvents = _eventsApi.GroupEvents(new GetGroupEventsRequest {
                GroupId = id, Status = "cancelled"
            });

            await Task.WhenAll(completedEvents, cancelledEvents);

            var events = new List <GetGroupEventsResponse>();

            events.AddRange(completedEvents.Result.Result);
            events.AddRange(cancelledEvents.Result.Result);

            var response = new ApiSuccessResponse <IEnumerable <GetGroupEventsResponse> >
            {
                Code   = 200,
                Result = events.OrderByDescending((x) => x.Date)
            };

            return(Ok(response));
        }
Ejemplo n.º 6
0
        public IActionResult Ok <T>(T response)
        {
            var reponse = new ApiSuccessResponse <T>(response);

            return(base.Ok(reponse));
        }