コード例 #1
0
        // GET: Profile/Post
        public ActionResult Index()
        {
            string lang = Request.Cookies.Get("languageCookie").Value;
            CommunitiesApiController communitydata = new CommunitiesApiController();
            PostVM postModel = new PostVM();

            postModel.communities    = new SelectList(communitydata.GetCommunityList(lang), "Id", "Name");
            postModel.answerTypes    = new SelectList(apiData.GetAnswerTypesList(lang), "answerType", "answerTypeName");
            postModel.indexQuestions = apiData.Get().ToList();

            // return PartialView("_Feed", postModel);
            return(View(postModel));
        }
コード例 #2
0
        public void GetPostById_ReturnOnePost(int id)
        {
            // Arrange
            var testProducts   = GetTestPosts();
            var postService    = new Mock <IPostService>();
            var commentService = new Mock <ICommentService>();
            var controller     = new PostApiController(postService.Object, commentService.Object);

            // Act
            postService.Setup(service => service.GetPostEntity(id)).Returns(testProducts.Find(p => p.Id == id));
            var result = controller.Get(id);

            // Assert
            Assert.AreEqual(id, result.Id);
        }
コード例 #3
0
        public ActionResult Index()
        {
            PostVM objVM = new PostVM();

            objVM.UserId = User.Identity.GetUserId();
            if (objVM.UserId == null || objVM.UserId == string.Empty)
            {
                objVM.indexQuestions = apiData.Get().ToList();
            }
            else
            {
                objVM.indexQuestions = apiData.GetByUserIdAndCommunity(objVM.UserId);
            }

            //return RedirectToAction("Index", "Post", new { Area = "Profile" });
            return(View(objVM));
        }