Esempio n. 1
0
        public async Task <ActionResult <List <MessageResponse> > > GetMessages([FromQuery] int no = 20)
        {
            var messages = await _timelineService.GetMessagesForAnonymousUser(no, includeFlaggedMessages : false);

            return(Ok(messages.Select(msg => new MessageResponse()
            {
                Content = msg.Text,
                PublishDate = msg.PublishDate,
                Author = msg.Author.Username
            })));
        }
Esempio n. 2
0
        public async Task <IActionResult> PublicTimeline()
        {
            ViewData["title"] = "Public Timeline";

            var includeFlaggedMessages = User.IsInRole(AuthRoles.Administrator);

            var messages = await _timelineService.GetMessagesForAnonymousUser(ResultsPerPage, includeFlaggedMessages);

            var mapped = messages.Select(message => new TimelineMessageVM(
                                             message.ID,
                                             new UserVM(
                                                 message.Author.ID,
                                                 message.Author.Username,
                                                 message.Author.Email),
                                             message.Text,
                                             message.PublishDate,
                                             message.IsFlagged
                                             )).ToList();

            var vm = new UserTimelineVM(null, false, mapped);

            return(View("Timeline", vm));
        }