예제 #1
0
        public async Task <IActionResult> GetMessages(int UserId, [FromQuery] MessagesParam messagesParam)
        {
            if (UserId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            messagesParam.UserID = UserId;

            var messages = await _repo.GetMessageForUser(messagesParam);

            var MessagesToReturn = _mapper.Map <IEnumerable <MessageToReturnDto> >(messages);

            Response.AddPaginationHeader(messages.CurrentPage, messages.PageSize, messages.TotalCount, messages.TotalPages);
            return(Ok(MessagesToReturn));
        }