Пример #1
0
        public List <CommentUnion> GetComments(Int32 customerId, Int32 parentId, CommonUnit.CommentType type)
        {
            menuzRusDataContext            db = new menuzRusDataContext(base.connectionString);
            CheckMenuComment               checkMenuComment;
            List <CommentUnion>            retVal            = new List <CommentUnion>();
            IEnumerable <Comment>          comments          = db.Comments.Where(m => m.CustomerId == customerId);
            IEnumerable <CheckMenuComment> checkMenuComments = db.CheckMenuComments.Where(m => m.ParentId == parentId && m.Type == (Int32)type);

            foreach (Comment comment in comments)
            {
                CommentUnion comm = new CommentUnion();
                comm.id          = comment.id;
                comm.CommentText = comment.CommentText;
                comm.ParentId    = 0;
                comm.Selected    = false;
                checkMenuComment = checkMenuComments.FirstOrDefault(m => m.CommentId == comment.id);
                if (checkMenuComment != default(CheckMenuComment))
                {
                    comm.ParentId = checkMenuComment.ParentId;
                    comm.Selected = true;
                }
                retVal.Add(comm);
            }

            return(retVal);
        }
Пример #2
0
        public List<CommentUnion> GetComments(Int32 customerId, Int32 parentId, Common.CommentType type) {
            menuzRusDataContext db = new menuzRusDataContext(base.connectionString);
            CheckMenuComment checkMenuComment;
            List<CommentUnion> retVal = new List<CommentUnion>();
            IEnumerable<Comment> comments = db.Comments.Where(m => m.CustomerId == customerId);
            IEnumerable<CheckMenuComment> checkMenuComments = db.CheckMenuComments.Where(m => m.ParentId == parentId && m.Type == (Int32)type);
            foreach (Comment comment in comments) {
                CommentUnion comm = new CommentUnion();
                comm.id = comment.id;
                comm.CommentText = comment.CommentText;
                comm.ParentId = 0;
                comm.Selected = false;
                checkMenuComment = checkMenuComments.FirstOrDefault(m => m.CommentId == comment.id);
                if (checkMenuComment != default(CheckMenuComment)) {
                    comm.ParentId = checkMenuComment.ParentId;
                    comm.Selected = true;
                }
                retVal.Add(comm);
            }

            return retVal;
        }