public async Task <JsonResult> GetInvites(
            [FromHeader(Name = "Token")] string access_token,
            int eventId,
            [FromQuery(Name = "State")] int?state
            )
        {
            TokenDto tk = new TokenDto
            {
                AccessToken = access_token
            };

            var response = await _inviteService.GetInvites(tk, eventId, state);

            if (response.Errors != null)
            {
                Response.StatusCode = 401;
                return(new JsonResult(response.Errors));
            }

            Response.StatusCode = 200;
            return(new JsonResult(response.Result));
        }
Ejemplo n.º 2
0
        public IActionResult GetAll([FromQuery] InviteQueryFilter filters)
        {
            var invites    = _inviteService.GetInvites(filters);
            var invitesDto = _mapper.Map <IEnumerable <InviteDto> >(invites);

            var metadata = new Metadata
            {
                TotalCount      = invites.TotalCount,
                PageSize        = invites.PageSize,
                CurrentPage     = invites.CurrentPage,
                TotalPages      = invites.TotalPages,
                HasNextPage     = invites.HasNextPage,
                HasPreviousPage = invites.HasPreviousPage,
                NextPageUrl     = _uriService.GetPaginationUri(Url.RouteUrl(nameof(GetAll))).ToString(),
                PreviousPageUrl = _uriService.GetPaginationUri(Url.RouteUrl(nameof(GetAll))).ToString()
            };

            var response = new ApiResponse <IEnumerable <InviteDto> >(invitesDto)
            {
                Meta = metadata
            };

            return(Ok(response));
        }