Exemplo n.º 1
0
        public ActionResult List(int recipeId = 0, int total = 0)
        {
            var pageInfo = new PageInfo(AppConfigs.CommentsPageSize, 1);
            var vm = new ListRecipeCommentViewModel { RecipeId = recipeId, Total = total, HighlightComments = new List<RecipeComment>() };

            var feedback = _commentRepository.GetRecipeComments(recipeId, pageInfo);
            var feedback2 = _commentRepository.GetHighlightRecipeComments(recipeId, AppConfigs.HighlightCommentNumber);
            if (feedback.Success && feedback2.Success)
            {
                vm.Comments = feedback.Data;
                vm.HighlightComments = feedback2.Data;
                vm.CurrentUserId = CurrentUser != null ? CurrentUser.UserInfo.Id : 0;
                vm.HasMore = vm.Total > pageInfo.PageSize * pageInfo.PageNo;
            }
            return View(vm);
        }
Exemplo n.º 2
0
        public ActionResult Comment(RecipeComment pc)
        {
            var vm = new ListRecipeCommentViewModel { Comments = new List<RecipeComment>(), CurrentUserId = CurrentUser.UserInfo.Id };
            if (ModelState.IsValid)
            {
                pc.PostedById = CurrentUser.UserInfo.Id;

                // Call Repository to perform insert
                var feedback = _commentRepository.InsertRecipeComment(pc);
                if (feedback.Success)
                {
                    vm.Comments.Add(feedback.Data);
                    return View(vm);
                }
            }
            return View(vm);
        }
Exemplo n.º 3
0
        public ActionResult ListMore(int recipeId = 0, int total = 0, int page = 1)
        {
            var pageInfo = new PageInfo(AppConfigs.CommentsPageSize, page);
            var vm = new ListRecipeCommentViewModel { RecipeId = recipeId, Total = total };

            var feedback = _commentRepository.GetRecipeComments(recipeId, pageInfo);
            if (feedback.Success)
            {
                vm.Comments = feedback.Data;
                vm.CurrentUserId = CurrentUser != null ? CurrentUser.UserInfo.Id : 0;
                vm.HasMore = vm.Total > pageInfo.PageSize * pageInfo.PageNo;
            }
            return View(vm);
        }