Esempio n. 1
0
        /// <summary>
        /// 获取评论、问题列表
        /// </summary>
        /// <param name="courseid">课程ID 可为空</param>
        /// <param name="type">InteractiveType 类型</param>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="index">页码</param>
        /// <param name="total">总记录数</param>
        /// <param name="pages">总页数</param>
        /// <returns></returns>
        public static List<Entity.UserInteraction> GetUserInteractions(string courseid, InteractiveType type, int pageSize, int index, out int total, out int pages)
        {
            List<Entity.UserInteraction> list = new List<UserInteraction>();

            string table = "UserInteraction ui join Users u on ui.UserID=u.UserID";
            string columns = "ui.*,u.PetName ,u.PhotoPath";
            StringBuilder build = new StringBuilder();
            build.Append(" ui.Status <> 9 and ui.IsReply='0' and ui.Type=" + (int)type);

            if (!string.IsNullOrEmpty(courseid) && courseid != "1")
            {
                build.Append(" and ui.CourseID='" + courseid + "'");
            }

            DataTable dt = CommonBusiness.GetPagerData(table, columns, build.ToString(), "ui.ID", pageSize, index, out total, out pages);

            foreach (DataRow dr in dt.Rows)
            {
                UserInteraction model = new UserInteraction();
                model.FillData(dr);
                list.Add(model);
            }

            return list;
        }
Esempio n. 2
0
        /// <summary>
        /// 根据ID评论回复、问题答案列表
        /// </summary>
        /// <param name="userInteractionID">评论、问题ID</param>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="index">页码</param>
        /// <param name="total">总记录数</param>
        /// <param name="pages">总页数</param>
        /// <returns></returns>
        public static List<Entity.UserInteraction> GetUserInteractionReplysByID(int userInteractionID, int pageSize, int index, out int total, out int pages)
        {
            List<Entity.UserInteraction> list = new List<UserInteraction>();

            string table = "UserInteraction ui join Users u on ui.UserID=u.UserID";
            string columns = "ui.*,u.PetName ,u.PhotoPath";
            StringBuilder build = new StringBuilder();
            build.Append(" ui.Status <> 9 and ui.IsReply='1' and ui.originalid=" + userInteractionID);

            DataTable dt = CommonBusiness.GetPagerData(table, columns, build.ToString(), "ui.ID", pageSize, index, out total, out pages);

            foreach (DataRow dr in dt.Rows)
            {
                UserInteraction model = new UserInteraction();
                model.FillData(dr);
                list.Add(model);
            }

            //填充回复实体
            foreach (var model in list)
            {
                model.ReplyEntity = list.Where(m => m.ID == model.ReplyID.Value && m.ID != userInteractionID).FirstOrDefault();
            }

            return list;
        }