/// <summary> /// Load the information from the table <c>Idea</c> to the list of entities according to the parameters send /// </summary> /// <param name="ideaId">idea id</param> /// <param name="userId">user id</param> /// <returns>a list of entities according to the parameters send</returns> public IdeasPaging IdeaPagingById(int ideaId, int?userId) { IdeasPaging idea = new IdeasPaging(); this.Session.CreateCommand("CTIdeaPagingById", true); this.Session.AddParameter("@IdeaId", ideaId, System.Data.ParameterDirection.Input, System.Data.DbType.Int32); this.Session.AddParameter("@UserId", userId, System.Data.ParameterDirection.Input, System.Data.DbType.Int32); this.Session.ExecuteReader(); while (Session.Read()) { idea = new IdeasPaging(this.Session.Reader); } return(idea); }
public ActionResult Idea(int ideaId) { int total = 0; int?currentUserId = null; if (User.Identity.IsAuthenticated) { currentUserId = ((CustomPrincipal)User).UserId; } IdeaRepository idea = new IdeaRepository(SessionCustom); CommentRepository comment = new CommentRepository(SessionCustom); QuestionRepository question = new QuestionRepository(SessionCustom); List <IdeasPaging> ideas = new List <IdeasPaging>(); IdeasPaging singleIdea = idea.IdeaPagingById(ideaId, currentUserId); ideas.Add(singleIdea); foreach (IdeasPaging item in ideas) { item.CollComment = comment.CommentsPaging(1, 1, out total, item.IdeaId.Value); if (item.CollComment.Count > 0) { item.CollComment[0].CommentCount = total; } } if (ideas.Count > 0) { question.Entity.ContentId = singleIdea.ContentId; question.LoadByKey(); if (question.Entity.EndDate.HasValue) { ideas[0].QuestionType = question.Entity.Type; } } ViewBag.CurrentUserId = currentUserId; return(this.View("_CardIdeasList", ideas)); }