示例#1
0
        public NoteCommentContent AddCommentContent(NoteCommentContent commentContent)
        {
            CommentContentEntity entity = commentContent.ToEntity();

            this.dbContext.CommentContents.Add(entity);
            this.dbContext.SaveChanges();
            return(entity.ToModel());
        }
示例#2
0
        public List <NoteCommentContent> GetCommentContentByCommentId(int commentId)
        {
            try
            {
                if (commentId <= 0)
                {
                    return(null);
                }

                DbParameter[] parameters = new DbParameter[]
                {
                    new SqlParameter()
                    {
                        ParameterName = SpParamsOfCommentContent.Sp_Select_CommentContentByCommentId_CommentId,
                        Value         = commentId
                    }
                };

                using (DataSet dataSet = DbHelper.Instance.RunProcedureGetDataSet(SpNamesOfCommentContent.Sp_Select_CommentContentByCommentId, parameters))
                {
                    List <NoteCommentContent> commentContents = new List <NoteCommentContent>();

                    if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count != 0)
                    {
                        DataRowCollection    dataRows    = dataSet.Tables[0].Rows;
                        DataColumnCollection dataColumns = dataSet.Tables[0].Columns;

                        foreach (DataRow dataRow in dataRows)
                        {
                            CommentContentEntity entity = new CommentContentEntity()
                            {
                                Id         = (int)dataRow[dataColumns[0]],
                                CommentId  = (int)dataRow[dataColumns[1]],
                                Type       = (int)dataRow[dataColumns[2]],
                                Content    = (string)dataRow[dataColumns[3]],
                                CreateTime = (DateTime)dataRow[dataColumns[4]]
                            };

                            commentContents.Add(entity.ToModel());
                        }
                    }

                    return(commentContents);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        public NoteCommentContent GetCommentContentById(int id)
        {
            CommentContentEntity entity = this.dbContext.CommentContents.FirstOrDefault(cc => cc.Id == id);

            return(entity == null ? null : entity.ToModel());
        }