Beispiel #1
0
        public virtual ActionResult HotMainPost(string system)
        {
            List <MainPost> list = new List <MainPost>();
            RecommendedMainPostViewModel model = new RecommendedMainPostViewModel();

            model.System = system;
            switch (system)
            {
            case "Question":
                model.Name      = "Câu hỏi";
                model.Type      = RecommendedMainPostTypeEnum.Hot;
                model.MainPosts = _qService.GetQuestions(Constant.Question.String.HomeHotTab).Take(5).ToList <MainPost>();
                break;

            case "Blog":
                model.Name      = "Bài viết";
                model.Type      = RecommendedMainPostTypeEnum.Hot;
                model.MainPosts = _bService.GetArticles(Constant.Blog.String.HomeHotTab, 0, _currentUserId).Take(5).ToList <MainPost>();
                break;

            case "Discussion":
                model.Name      = "Thảo luận";
                model.Type      = RecommendedMainPostTypeEnum.Hot;
                model.MainPosts = _dService.GetDiscussions(Constant.Discussion.String.HomeHotTab).Take(5).ToList <MainPost>();
                break;

            default:
                model.Name      = "Bài Viết";
                model.Type      = RecommendedMainPostTypeEnum.Hot;
                model.System    = "Blog";
                model.MainPosts = _bService.GetArticles(Constant.Blog.String.HomeHotTab, _currentUserId).Take(5).ToList <MainPost>();
                break;
            }
            return(PartialView("../CommonWidget/Widgets/_RecommendedMainPost", model));
        }
Beispiel #2
0
        public IActionResult Detail(long id, int page = 1)
        {
            Room             room        = _roomService.GetRoom(id);
            DiscussViewModel discussions = _discussionService.GetDiscussions(id, page);

            ViewBag.Disc = discussions;
            return(View(room));
        }
Beispiel #3
0
        public ActionResult MyActivity(string tab = "posts")
        {
            //Post
            List <Discussion> discussions = dService.GetDiscussions(User.Identity.GetUserId <int>());
            List <Question>   questions   = qService.GetQuestions(User.Identity.GetUserId <int>());
            List <Article>    articles    = bService.GetArticles(User.Identity.GetUserId <int>());
            List <Answer>     answers     = qService.GetAnswers(User.Identity.GetUserId <int>());

            //Bookmark
            List <Discussion> bookmarkDiscussions = dService.GetDiscussions(Constant.Discussion.String.BookmarkDiscussion);
            List <Question>   bookmarkQuestions   = qService.GetQuestions(Constant.Question.String.BookmarkQuestion);
            List <Article>    bookmarkArticles    = bService.GetArticles(Constant.Blog.String.BookmarkArticle);

            //Invited
            List <MainPost> invitedMainPosts = cService.GetMainPosts("Invited");

            List <Notification> notifications = cService.GetNotifications();
            List <Tag>          tags          = aService.GetFavoriteTags(User.Identity.GetUserId <int>());
            List <Conversation> convers       = rService.GetConversations(_currentUserId);
            List <ConversationPreviewViewModel> conversations;
            ConversationDetailViewModel         conversation;

            if (convers.Count != 0)
            {
                conversations =
                    CP_MathHub.Helper.ListHelper.ConversationsToConversationViewModels(convers, _currentUserId);
                conversation = new ConversationDetailViewModel();
                conversation.SetDates(rService.GetAllConversationMessages(convers.First().Id));
                conversation.Name = rService.GetConversationName(convers.First());
                conversation.Id   = convers.First().Id;

                Conversation conver = rService.GetConversation(convers.First().Id);
                for (int i = 0; i < conver.Attendances.Count; i++)
                {
                    conver.Attendances.ElementAt(i).SeenDate = DateTime.Now;
                }
                rService.UpdateConversation(conver);
            }
            else
            {
                conversations      = new List <ConversationPreviewViewModel>();
                conversation       = new ConversationDetailViewModel();
                conversation.Dates = new List <MesagesOfDate>();
                conversation.Name  = "";
            }

            ActivityViewModel model = new ActivityViewModel();

            //Post
            model.DiscussionList = discussions;
            model.QuestionList   = questions;
            model.ArticleList    = articles;
            model.AnswerList     = answers;
            //bookmark
            model.BookmarkArticleList    = bookmarkArticles;
            model.BookmarkDiscussionList = bookmarkDiscussions;
            model.BookmarkQuestionList   = bookmarkQuestions;
            //Invited
            model.InvitedList = invitedMainPosts;

            model.NotificationList = notifications;
            model.TagList          = tags;
            //model.AnswerNum = qService.CountUserAnswer(User.Identity.GetUserId<int>());
            //model.ArticleNum = bService.CountUserArticle(User.Identity.GetUserId<int>());
            //model.DiscussionNum = dService.CountUserDiscussion(User.Identity.GetUserId<int>());
            //model.QuestionNum = qService.CountUserQuestion(User.Identity.GetUserId<int>());
            model.Conversations = conversations;
            model.Conversation  = conversation;
            //var cookie = new HttpCookie("returnUrl", Request.Url.AbsolutePath + Request.Url.Query);
            //cookie.Expires = DateTime.Now.AddMinutes(5);
            //Response.Cookies.Add(cookie);
            ViewBag.System = Constant.String.ProfileSystem;
            ViewBag.Tab    = tab;
            return(View("Views/ActivityView", model));
        }
 public IActionResult Get()
 {
     return(Ok(_repo.GetDiscussions()));
 }