Beispiel #1
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <CommentEntity> GetCommentAll()
        {
            string sql = @"SELECT [Id],[ProductId], [OrderCode],[OrderDetailId],[ProductName],[ProductStar],[SeviceStar],[TrafficStar],[CommentContent],[ClientType],[HasPic],[IpAddress],[MemId],[CreateTime],[Status],[CheckManId],[CheckTime],[ReplyContent] from dbo.[Comment] WITH(NOLOCK)	";
            IList <CommentEntity> entityList = new List <CommentEntity>();
            DbCommand             cmd        = db.GetSqlStringCommand(sql);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    CommentEntity entity = new CommentEntity();
                    entity.Id             = StringUtils.GetDbInt(reader["Id"]);
                    entity.ProductId      = StringUtils.GetDbInt(reader["ProductId"]);
                    entity.OrderCode      = StringUtils.GetDbLong(reader["OrderCode"]);
                    entity.OrderDetailId  = StringUtils.GetDbInt(reader["OrderDetailId"]);
                    entity.ProductName    = StringUtils.GetDbString(reader["ProductName"]);
                    entity.ProductStar    = StringUtils.GetDbInt(reader["ProductStar"]);
                    entity.SeviceStar     = StringUtils.GetDbInt(reader["SeviceStar"]);
                    entity.TrafficStar    = StringUtils.GetDbInt(reader["TrafficStar"]);
                    entity.CommentContent = StringUtils.GetDbString(reader["CommentContent"]);
                    entity.ClientType     = StringUtils.GetDbInt(reader["ClientType"]);
                    entity.HasPic         = StringUtils.GetDbInt(reader["HasPic"]);
                    entity.IpAddress      = StringUtils.GetDbString(reader["IpAddress"]);
                    entity.MemId          = StringUtils.GetDbInt(reader["MemId"]);
                    entity.CreateTime     = StringUtils.GetDbDateTime(reader["CreateTime"]);
                    entity.Status         = StringUtils.GetDbInt(reader["Status"]);
                    entity.CheckManId     = StringUtils.GetDbInt(reader["CheckManId"]);
                    entity.CheckTime      = StringUtils.GetDbDateTime(reader["CheckTime"]);
                    entity.ReplyContent   = StringUtils.GetDbString(reader["ReplyContent"]);
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
Beispiel #2
0
        /// <summary>
        /// 判断当前节点是否已存在相同的
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int  ExistNum(CommentEntity entity)
        {
            ///id=0,判断总数,ID>0判断除自己之外的总数
            string sql = @"Select count(1) from dbo.[Comment] WITH(NOLOCK) ";

            string where = "where ";
            if (entity.Id == 0)
            {
                where = where + "[ProductId]=@ProductId";//即针对一个Id一个StyleId只能有一条评论
            }
            else
            {
                where = where + "[Id]<>@Id and [ProductId]=@ProductId";
            }
            sql = sql + where;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@ProductId", DbType.Int32, entity.ProductId);
            if (entity.Id > 0)
            {
                db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            }

            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
Beispiel #3
0
        /// <summary>
        /// 插入一条记录到表Comment,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="comment">待插入的实体对象</param>
        public int AddComment(CommentEntity entity)
        {
            string    sql = @"insert into Comment( [ProductId], [OrderCode],[OrderDetailId],[ProductName],[ProductStar],[SeviceStar],[TrafficStar],[CommentContent],[ClientType],[HasPic],[IpAddress],[MemId],[CreateTime],[Status],[CheckManId],[CheckTime],[ReplyContent])VALUES
			            ( @ProductId, @OrderCode,@OrderDetailId,@ProductName,@ProductStar,@SeviceStar,@TrafficStar,@CommentContent,@ClientType,@HasPic,@IpAddress,@MemId,@CreateTime,@Status,@CheckManId,@CheckTime,@ReplyContent);
			SELECT SCOPE_IDENTITY();"            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@ProductId", DbType.Int32, entity.ProductId);
            db.AddInParameter(cmd, "@OrderCode", DbType.String, entity.OrderCode);
            db.AddInParameter(cmd, "@OrderDetailId", DbType.Int32, entity.OrderDetailId);
            db.AddInParameter(cmd, "@ProductName", DbType.String, entity.ProductName);
            db.AddInParameter(cmd, "@ProductStar", DbType.Int32, entity.ProductStar);
            db.AddInParameter(cmd, "@SeviceStar", DbType.Int32, entity.SeviceStar);
            db.AddInParameter(cmd, "@TrafficStar", DbType.Int32, entity.TrafficStar);
            db.AddInParameter(cmd, "@CommentContent", DbType.String, entity.CommentContent);
            db.AddInParameter(cmd, "@ClientType", DbType.Int32, entity.ClientType);
            db.AddInParameter(cmd, "@HasPic", DbType.Int32, entity.HasPic);
            db.AddInParameter(cmd, "@IpAddress", DbType.String, entity.IpAddress);
            db.AddInParameter(cmd, "@MemId", DbType.Int32, entity.MemId);
            db.AddInParameter(cmd, "@CreateTime", DbType.DateTime, entity.CreateTime);
            db.AddInParameter(cmd, "@Status", DbType.Int32, entity.Status);
            db.AddInParameter(cmd, "@CheckManId", DbType.Int32, entity.CheckManId);
            db.AddInParameter(cmd, "@CheckTime", DbType.DateTime, entity.CheckTime);
            db.AddInParameter(cmd, "@ReplyContent", DbType.String, entity.ReplyContent);
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
        public async Task <ActionResult <CommentEntity> > PostCommentEntity(CommentEntity commentEntity)
        {
            _context.Comments.Add(commentEntity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCommentEntity", new { id = commentEntity.Id }, commentEntity));
        }
        public Commentary ToComment(CommentEntity commentEntity)
        {
            User       maker      = usersMapper.ToUser(commentEntity.Maker, new List <TeamEntity>());
            Commentary conversion = new Commentary(commentEntity.Id, commentEntity.Text, maker);

            return(conversion);
        }
Beispiel #6
0
 /// <summary>
 /// 添加评论确定按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void submit_Click(object sender, EventArgs e)
 {
     DataBase db = new DataBase();
     CommentEntity ce = new CommentEntity();
     ce.Agree = 0;
     ce.nid = int.Parse(Request.QueryString["nid"].ToString());
     ce.DisAgree = 0;
     ce.CommentTitle = "";
     ce.ConText = tb_comment.Text;
     ce.uid = int.Parse(Session["uid"].ToString());
     ce.UpTime = DateTime.Now;
     if (ce.ConText == "")
     {
         Response.Write("请填写评论内容!");
         return;
     }
     if (CommentOperation.AddComment(ce))
     {
         Response.Redirect("LoadComment.aspx?nid=" + ce.nid );
         return;
     }
     else
     {
         Response.Write("添加评论失败");
     }
 }
Beispiel #7
0
        protected void AddReview_Click(object sender, EventArgs e)
        {
            TextBox         ReviewTitleTextBox        = null;
            TextBox         ReviewTextBox             = null;
            RadioButtonList ReviewRateRadioButtonList = null;

            foreach (RepeaterItem item in ProductRepeater.Items)
            {
                ReviewTitleTextBox = (TextBox)item.FindControl("ReviewTitleTextBox");
                ReviewTextBox      = (TextBox)item.FindControl("ReviewTextBox")
                ;
                ReviewRateRadioButtonList = (RadioButtonList)item.FindControl("ReviewRateRadioButtonList");
            }



            CommentEntity comment = new CommentEntity();

            comment.ProductId = Convert.ToInt32(ViewState["ProductId"]);
            comment.Title     = ReviewTitleTextBox.Text;
            comment.Content   = ReviewTextBox.Text;
            comment.RateId    = GetRateIdByRadioButtonListSelection(Convert.ToInt32(ReviewRateRadioButtonList.SelectedValue));
            comment.Status    = false;
            comment.Save();

            LoadData();
        }
Beispiel #8
0
 public ActionResult GetCommentsList(CommentListViewModel model)
 {
     if (ModelState.IsValid)
     {
         UserEntity    currentUser = _userService.GetUserByEmail(User.Identity.Name);
         CommentEntity newComment  = new CommentEntity {
             LotId = model.LotId, Text = model.Text, Date = DateTime.Now, UserId = currentUser.Id
         };
         _commentService.CreateComment(newComment);
         if (!Request.IsAjaxRequest())
         {
             return(RedirectToAction("LotDetails", new { id = model.LotId }));
         }
         else
         {
             model.Comments = _commentService.GetAllCommentEntitiesByLotId(model.LotId).Select(c => c.ToMvcComment()).OrderBy(c => c.Date);
             return(PartialView(model));
         }
     }
     if (!Request.IsAjaxRequest())
     {
         return(RedirectToAction("LotDetails", new { id = model.LotId }));
     }
     else
     {
         model.Comments = _commentService.GetAllCommentEntitiesByLotId(model.LotId).Select(c => c.ToMvcComment()).OrderBy(c => c.Date);
         return(PartialView(model));
     }
 }
Beispiel #9
0
        /// <summary>
        /// 通过数据读取器生成实体类
        /// </summary>
        /// <param name="rdr"></param>
        /// <returns></returns>
        private static CommentEntity GetEntityFromrdr(NullableDataReader rdr)
        {
            CommentEntity info = new CommentEntity();

            info.CommentID      = rdr.GetInt32("CommentID");
            info.GeneralID      = rdr.GetInt32("GeneralID");
            info.NodeID         = rdr.GetInt32("NodeID");
            info.TopicID        = rdr.GetInt32("TopicID");
            info.CommentTitle   = rdr.GetString("CommentTitle");
            info.Email          = rdr.GetString("Email");
            info.Content        = rdr.GetString("Content");
            info.Face           = rdr.GetString("Face");
            info.UpdateDateTime = rdr.GetNullableDateTime("UpdateDateTime");
            info.Position       = rdr.GetInt32("Position");
            info.IsPassed       = rdr.GetBoolean("IsPassed");
            info.Agree          = rdr.GetInt32("Agree");
            info.Oppose         = rdr.GetInt32("Oppose");
            info.Neutral        = rdr.GetInt32("Neutral");
            info.Score          = rdr.GetInt32("Score");
            info.IP             = rdr.GetString("IP");
            info.IsElite        = rdr.GetBoolean("IsElite");
            info.IsPrivate      = rdr.GetBoolean("IsPrivate");
            info.UserName       = rdr.GetString("UserName");
            info.Reply          = rdr.GetString("Reply");
            info.ReplyAdmin     = rdr.GetString("ReplyAdmin");
            info.ReplyDatetime  = rdr.GetNullableDateTime("ReplyDatetime");
            info.ReplyIsPrivate = rdr.GetBoolean("ReplyIsPrivate");
            info.ReplyUserName  = rdr.GetString("ReplyUserName");
            return(info);
        }
Beispiel #10
0
        /// <summary>
        /// 更新一条记录(异步方式)
        /// </summary>
        /// <param name="entity">实体模型</param>
        /// <returns></returns>
        public virtual async Task <bool> UpdateAsync(CommentEntity entity)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            GetParameters(entity, dict);
            string strSQL = "Update Comment SET " +
                            "GeneralID = @GeneralID," +
                            "NodeID = @NodeID," +
                            "TopicID = @TopicID," +
                            "CommentTitle = @CommentTitle," +
                            "Email = @Email," +
                            "Content = @Content," +
                            "Face = @Face," +
                            "UpdateDateTime = @UpdateDateTime," +
                            "Position = @Position," +
                            "IsPassed = @IsPassed," +
                            "Agree = @Agree," +
                            "Oppose = @Oppose," +
                            "Neutral = @Neutral," +
                            "Score = @Score," +
                            "IP = @IP," +
                            "IsElite = @IsElite," +
                            "IsPrivate = @IsPrivate," +
                            "UserName = @UserName," +
                            "Reply = @Reply," +
                            "ReplyAdmin = @ReplyAdmin," +
                            "ReplyDatetime = @ReplyDatetime," +
                            "ReplyIsPrivate = @ReplyIsPrivate," +
                            "ReplyUserName = @ReplyUserName" +
                            " WHERE " +

                            "CommentID = @CommentID";

            return(await Task.Run(() => _DB.ExeSQLResult(strSQL, dict)));
        }
Beispiel #11
0
        public static CommentEntity CommentImageDTO_To_CommentEntity(CommentImageDTO commentImageDTO)
        {
            var           mapper        = new MapperConfiguration(cfg => cfg.CreateMap <CommentImageDTO, CommentEntity>()).CreateMapper();
            CommentEntity commentEntity = mapper.Map <CommentImageDTO, CommentEntity>(commentImageDTO);

            return(commentEntity);
        }
Beispiel #12
0
 /// <summary>
 /// 把实体类转换成键/值对集合
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="dict"></param>
 private static void GetParameters(CommentEntity entity, Dictionary <string, object> dict)
 {
     dict.Add("CommentID", entity.CommentID);
     dict.Add("GeneralID", entity.GeneralID);
     dict.Add("NodeID", entity.NodeID);
     dict.Add("TopicID", entity.TopicID);
     dict.Add("CommentTitle", entity.CommentTitle);
     dict.Add("Email", entity.Email);
     dict.Add("Content", entity.Content);
     dict.Add("Face", entity.Face);
     dict.Add("UpdateDateTime", entity.UpdateDateTime);
     dict.Add("Position", entity.Position);
     dict.Add("IsPassed", entity.IsPassed);
     dict.Add("Agree", entity.Agree);
     dict.Add("Oppose", entity.Oppose);
     dict.Add("Neutral", entity.Neutral);
     dict.Add("Score", entity.Score);
     dict.Add("IP", entity.IP);
     dict.Add("IsElite", entity.IsElite);
     dict.Add("IsPrivate", entity.IsPrivate);
     dict.Add("UserName", entity.UserName);
     dict.Add("Reply", entity.Reply);
     dict.Add("ReplyAdmin", entity.ReplyAdmin);
     dict.Add("ReplyDatetime", entity.ReplyDatetime);
     dict.Add("ReplyIsPrivate", entity.ReplyIsPrivate);
     dict.Add("ReplyUserName", entity.ReplyUserName);
 }
Beispiel #13
0
 public void Update(Comment source, CommentEntity destination)
 {
     destination.User      = new UserEntity(source.User);
     destination.TimeStamp = source.TimeStamp;
     destination.Message   = source.Message;
     destination.Id        = source.Id;
 }
Beispiel #14
0
        public void StartUp()
        {
            testMapper = new CommentMapper();
            UserId identity = new UserId
            {
                Name     = "aName",
                Surname  = "aSurname",
                UserName = "******",
                Password = "******",
                Email    = "*****@*****.**"
            };
            Mock <User> stub = new Mock <User>(identity, true);

            comment       = new Commentary("this is a comment", stub.Object);
            commentEntity = new CommentEntity()
            {
                Id    = 3,
                Text  = "another comment",
                Maker = new UserEntity()
                {
                    Name     = "aName",
                    Surname  = "aSurname",
                    UserName = "******",
                    Password = "******",
                    Email    = "*****@*****.**"
                }
            };
        }
Beispiel #15
0
        public virtual IComment Execute(CommandContext commandContext)
        {
            if (ReferenceEquals(ProcessInstanceId, null) && ReferenceEquals(TaskId, null))
            {
                throw new ProcessEngineException("Process instance id and ITask id is null");
            }

            EnsureUtil.EnsureNotNull("Message", Message);

            var userId  = commandContext.AuthenticatedUserId;
            var comment = new CommentEntity();

            comment.UserId = userId;
            //comment.Type = CommentEntity.TYPE_COMMENT;
            comment.Time              = ClockUtil.CurrentTime;
            comment.TaskId            = TaskId;
            comment.ProcessInstanceId = ProcessInstanceId;
            comment.Action            = EventFields.ActionAddComment;

            var eventMessage = Message.Replace("\\s+", " ");

            if (eventMessage.Length > 163)
            {
                eventMessage = eventMessage.Substring(0, 160) + "...";
            }
            comment.Message = eventMessage;

            comment.FullMessage = Message;

            commandContext.CommentManager.Insert(comment);

            return((IComment)comment);
        }
Beispiel #16
0
        public async Task <BaseResult <bool> > Disable(string comment_id, string disable_desc, int type)
        {
            if (string.IsNullOrEmpty(comment_id))
            {
                return(new BaseResult <bool>(808));
            }
            var           str           = "";
            CommentEntity commentEntity = await commentRepository.GetAsync(c => c.comment_id.Equals(comment_id));

            if (string.IsNullOrEmpty(commentEntity.disabledesc))
            {
                str = "{'disable':'" + commentEntity.disable + "','disable_desc':'" + disable_desc + "'}";
            }
            else
            {
                str = commentEntity.disabledesc + ",{'disable':'" + commentEntity.disable + "','disable_desc':'" + disable_desc + "'}";
            }
            CommentEntity comment = new CommentEntity()
            {
                comment_id  = comment_id,
                disabledesc = str,
                disable     = type
            };

            var isTrue = await commentRepository.UpdateAsync(comment, true, true, c => c.disable, c => c.disabledesc);

            if (!isTrue)
            {
                return(new BaseResult <bool>(201, false));
            }
            return(new BaseResult <bool>(200, true));
        }
        public void ChangeStatusComment(bool status, int id)
        {
            CommentEntity comment = new CommentEntity(id);

            comment.Status = status;
            comment.Save();
        }
Beispiel #18
0
 public async Task AddComment(CommentEntity comment)
 {
     await Task.Run(() =>
     {
         _commentService.AddComment(comment);
     });
 }
Beispiel #19
0
        public async Task RegisterCommentAsync(CommentEntity comment)
        {
            var data = _convertComment.Execute(comment);
            await DbSet.AddAsync(data);

            await _context.SaveChangesAsync();
        }
Beispiel #20
0
        public ActionResult AddComment(CommentEntity model, bool captchaValid, string captchaErrorMessage)
        {
            string error = CitizenPortal.Resources.Views.Data.Comment.FormError;

            if (!ModelState.IsValid)
            {
                error = CitizenPortal.Resources.Views.Data.Comment.FormErrorFields;
            }
            else if (!captchaValid)
            {
                error = CitizenPortal.Resources.Views.Data.Comment.FormErrorCaptcha;
            }
            else
            {
                try
                {
                    // Update Azure Table
                    AzureHelper.GetCloudTable("Comments").Execute(TableOperation.Insert(model));

                    return(Json(model));
                }
                catch (Exception ex)
                {
                    error = ex.Message;
                }
            }

            model.Error = error;
            return(Json(model));
        }
        public async Task <IActionResult> PutCommentEntity(Guid id, CommentEntity commentEntity)
        {
            if (id != commentEntity.Id)
            {
                return(BadRequest());
            }

            _context.Entry(commentEntity).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CommentEntityExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        /// Default constructur
        /// </summary>
        public ObjectCommentRepository()
        {
            _comments = new Collection <CommentEntity>();

            Random rand = new Random();

            for (long i = 1; i < Repository.UserPostRepositoryInstance.GetCount(); i++)
            {
                // random count of comments for post
                for (int j = 1; j < rand.Next(1, 100); j++)
                {
                    if (Repository.UserPostRepositoryInstance.IsExists(i))
                    {
                        CommentEntity comment = new CommentEntity();
                        comment.Id         = identityIdCounter++;
                        comment.CreatedUTC = DateTime.Now;
                        comment.PostId     = i;
                        comment.UserId     = Repository.UserPostRepositoryInstance.Get(i).AuthorUserId;
                        comment.Message    = "";
                        for (int k = 0; k < rand.Next(1, 10); k++)
                        {
                            comment.Message += "Nice post!";
                        }

                        _comments.Add(comment);
                    }
                }
            }
        }
Beispiel #23
0
        public bool DeleteCommentByAvatar(int userId = 0, bool?admin = null, int commentId = 0)
        {
            var comment = new CommentEntity();

            if (admin == true)
            {
                var comments = _ctx.CommentEntity
                               .Include(c => c.ReplyTo).AsTracking()
                               .Include(l => l.Likes)
                               .Include(f => f.Flags)
                               .AsSingleQuery()
                               .ToList(); // to allow deletion of any user's post
                comment = comments.FirstOrDefault(c => c.Id == commentId);
            }
            else
            {
                var avatars = _ctx.AvatarEntity
                              .Include(c => c.Comments)
                              .ThenInclude(r => r.ReplyTo).AsTracking()
                              .AsSingleQuery()
                              .ToList();

                comment = avatars
                          .FirstOrDefault(c => c.Id == userId).Comments
                          .FirstOrDefault(r => r.Id == commentId);
            }
            if (comment != null)
            {
                _ctx.Remove(comment);
                return(Save());
            }
            return(false);
        }
Beispiel #24
0
        public async Task <Comment> CreateCommentAsync(Comment comment, Guid blogPostId, string userId, CancellationToken ct)
        {
            var blogPost = _context.BlogPosts.Where(r => r.Id == blogPostId).FirstOrDefault();

            if (blogPost == null)
            {
                return(null);
            }
            comment.Author = _context.Users.Find(userId);
            var newComment = new CommentEntity
            {
                Id                = Guid.NewGuid(),
                CreatedAt         = DateTimeOffset.Now,
                ModifedAt         = DateTimeOffset.Now,
                Content           = comment.Content,
                BlogPostEntityId  = blogPostId.ToString(),
                BlogPostEntity    = blogPost,
                ApplicationUserId = userId
            };

            blogPost.Comments.Add(newComment);
            _context.Comments.Add(newComment);
            await _context.SaveChangesAsync();

            return(comment);
        }
Beispiel #25
0
 public List<CommentEntity> GetCommentOrderByUcode(string ucode,string cellPhone)
 {
     List<CommentEntity> result = new List<CommentEntity>();
     try
     {
         StringBuilder strSql = new StringBuilder();
         string sCellPhone = "";
         if (!string.IsNullOrEmpty(sCellPhone))
         {
             sCellPhone =string.Format(" and CellPhone='{0}'",cellPhone);
         }
         strSql.AppendFormat(@"Select top 20 * from   [dbo].[D_DriverComment](nolock)
           where ucode='{0}' and Comment!='' {1} order by create_time desc;", ucode, sCellPhone);
         var dt = helper.GetDataTable(strSql.ToString());
         if (dt != null && dt.Rows.Count > 0)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 CommentEntity entity = new CommentEntity();
                 entity.CellPhone = dt.Rows[i]["Cellphone"]==DBNull.Value?"":dt.Rows[i]["Cellphone"].ToString();
                 entity.Comment = dt.Rows[i]["Comment"] == DBNull.Value ? "" : dt.Rows[i]["Comment"].ToString();
                 entity.CreateTime = dt.Rows[i]["create_time"] == DBNull.Value ? "" : Convert.ToDateTime(dt.Rows[i]["create_time"]).ToString("yyyy-MM-dd");
                 entity.Evaluate = dt.Rows[i]["Evaluate"] == DBNull.Value ? 0 :Convert.ToInt32(dt.Rows[i]["Evaluate"]);
                 entity.Ucode = dt.Rows[i]["ucode"] == DBNull.Value ? "" : dt.Rows[i]["ucode"].ToString();
                 result.Add(entity);
             }
         }
     }
     catch (Exception ex)
     {
         LogControl.WriteError(string.Format("{0}|GetCommentOrderByUcode获取失败|Error:{1}",DateTime.Now, ex.Message));
     }
     return result;
 }
Beispiel #26
0
        public async Task <ActionResult> SaveMessage([FromBody] CommentEntity param)
        {
            // 获取IP地址
            if (param.location != null)
            {
                if (Request.HttpContext.Connection.RemoteIpAddress != null)
                {
                    var ip = Request.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();
                    param.location = ip;
                }
            }

            param.createDate = DateTime.Now;
            param.targetId ??= 0;
            var flag = await _commentService.AddCommentAsync(param);

            // 发送邮件
            if (param.targetId == 0 || param.targetUserId == null)
            {
                return(Ok(flag));
            }
            var toComment = await _commentService.GetCommentByIdAsync(param.targetId.Value);

            var fromComment = await _commentService.GetCommentByIdAsync(param.id);

            flag = _emailHelper.ReplySendEmail(toComment, fromComment, SendEmailType.回复评论);
            return(Ok(flag));
        }
    internal static void Seed(BloggingDbContext dbContext)
    {
        var blog = new BlogEntity
        {
            Id      = 1,
            Title   = "每个人都有选择幸福的自由",
            Content = "每个人都要为自己的选择负责 很多前来心理咨询的来访者,几乎都是是还没有学会爱自己的人,也是还不大明白对自己负责",
            Created = new DateTime(2017, 3, 19),
        };

        dbContext.Blogs.AddOrUpdate(b => b.Id, blog);

        var firstComment = new CommentEntity
        {
            Id      = 1,
            Blog    = blog,
            Content = "我感同身受",
        };

        var secondComment = new CommentEntity
        {
            Id      = 2,
            BlogId  = 1, //两种指定外键的方式,或者指定BlogId,或者指定Blog, EF会自动算出来.
            Content = "我感同身受",
        };

        dbContext.Comments.AddOrUpdate(c => c.Id, firstComment);
        dbContext.Comments.AddOrUpdate(c => c.Id, secondComment);
    }
Beispiel #28
0
        /// <summary>
        /// 设置批注
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="suffix"></param>
        /// <param name="comment"></param>
        /// <param name="col1"></param>
        /// <param name="row1"></param>
        /// <param name="col2"></param>
        /// <param name="row2"></param>
        public static void SetCellComment(this ICell cell, CommentEntity entitiy)
        {
            ISheet        sheet        = cell.Sheet;
            IClientAnchor clientAnchor = sheet.Workbook.GetCreationHelper().CreateClientAnchor();

            clientAnchor.AnchorType = AnchorType.MoveDontResize.GetType().ToInt();
            clientAnchor.Dx1        = entitiy.Dx1;
            clientAnchor.Dy1        = entitiy.Dy1;
            clientAnchor.Dx2        = entitiy.Dx2;
            clientAnchor.Dy2        = entitiy.Dy2;
            clientAnchor.Col1       = cell.ColumnIndex;
            clientAnchor.Row1       = cell.RowIndex;
            clientAnchor.Col2       = cell.ColumnIndex + entitiy.Width;
            clientAnchor.Row2       = cell.RowIndex + entitiy.Height;

            IDrawing draw    = sheet.CreateDrawingPatriarch();
            IComment comment = draw.CreateCellComment(clientAnchor);

            comment.Visible = false;
            if (sheet.Workbook is HSSFWorkbook)
            {
                comment.String = new HSSFRichTextString(entitiy.Text);
            }
            else
            {
                comment.String = new XSSFRichTextString(entitiy.Text);
            }
            cell.CellComment = comment;
        }
Beispiel #29
0
        public async Task <bool> Handle(RegisterAnswerCommentCommand request, CancellationToken cancellationToken)
        {
            var question = await _questionRepository.GetByIdAsync(request.QuestionId);

            if (question == null)
            {
                return(false);
            }

            var answer = question.Answers.ToList().FirstOrDefault(answer => answer.Id == request.AnswerId);

            if (answer == null)
            {
                return(false);
            }

            var comment = new CommentEntity(
                request.UserId,
                request.Body
                );

            comment.DefineId(request.Id);
            comment.SetParent(answer);

            await _repository.RegisterCommentAsync(comment);

            return(true);
        }
        public ActionResult SaveContact([FromBody] CommentEntity objComment)
        {
            APIResponse objResponse = new APIResponse();

            try
            {
                if (ModelState.IsValid)
                {
                    DBResponse     obj = new DBResponse();
                    CommentDetails objCommentDetails = new CommentDetails();
                    obj        = objCommentDetails.SaveComment(objComment);
                    obj.Result = obj.ID > 0;
                    objResponse.StatusMessage = obj.Result ? "Thanks for reply." : AppMessage.SystemError;
                    objResponse.StatusCode    = obj.Result ? APIStatusCode.Success.ToString() : APIStatusCode.InternalError.ToString();;
                }
                else
                {
                    objResponse.StatusCode    = APIStatusCode.ValidationFailed.ToString();
                    objResponse.StatusMessage = "Please fill in all required fields";
                }
            }
            catch (Exception ex)
            {
                objResponse.StatusMessage = ex.Message;
                objResponse.StatusCode    = APIStatusCode.SystemError;
            }
            return(Ok(objResponse));
        }
Beispiel #31
0
        public bool CreateComment(CommentCreateRAO model)
        {
            if (model.Content == null)
            {
                return(false);
            }

            var comment = new CommentEntity
            {
                OwnerId  = _userId,
                Content  = model.Content,
                ParentId = model.ParentId,
                GroupId  = model.GroupId
            };

            using (var ctx = new ApplicationDbContext())
            {
                var parent = ctx.Comments.FirstOrDefault(c => c.CommentId == model.ParentId);

                if (parent == null && model.ParentId != 0)
                {
                    return(false);
                }

                ctx.Comments.Add(comment);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #32
0
 public static void Comment_Insert(CommentEntity ce)
 {
     using (MainDB db = new MainDB(BOAdv.MasterConnectionString))
     {
         db.StoredProcedures.Comment_Insert(ce);
     }
 }
Beispiel #33
0
 /// <summary>
 /// 添加评论
 /// </summary>
 /// <param name="ce">评论的实例</param>
 /// <returns>添加成功返回true,添加失败返回 false</returns>
 public static bool AddComment(CommentEntity ce)
 {
     DataBase db = new DataBase();
     try
     {
         string sql = string.Format("INSERT INTO tb_comment ( commentTitle, context, agree, disagree, uid, nid, uptime)VALUES  ( '{0}', '{1}','{2}', '{3}', '{4}','{5}','{6}')", ce.CommentTitle, ce.ConText, ce.Agree, ce.DisAgree, ce.uid, ce.nid, ce.UpTime);
         db.ExCommandNoBack(sql);
         return true;
     }
     catch
     {
         return false;
     }
 }
Beispiel #34
0
    public static CommentEntity GetComment(int commentId)
    {
        /*获取评论信息*/
        DataBase db = new DataBase();
        DataSet rs = db.RunProcReturn("select * from tb_comment where id=" + commentId, "tb_comment");
        if (rs.Tables[0].Rows.Count > 0)
        {
            CommentEntity ce = new CommentEntity();
            ce.Id = int.Parse(rs.Tables[0].Rows[0]["id"].ToString());
            ce.CommetTitle = rs.Tables[0].Rows[0]["commenttitle"].ToString();
            ce.ConText = rs.Tables[0].Rows[0]["context"].ToString();
            ce.Agree = int.Parse(rs.Tables[0].Rows[0]["agree"].ToString());
            ce.DisAgree = int.Parse(rs.Tables[0].Rows[0]["disagree"].ToString());
            ce.uid = int.Parse(rs.Tables[0].Rows[0]["uid"].ToString());
            ce.nid = int.Parse(rs.Tables[0].Rows[0]["nid"].ToString());
            ce.UpTime = DateTime.Parse(rs.Tables[0].Rows[0]["uptime"].ToString());

            return ce;
        }
        return null;
    }
Beispiel #35
0
 /// <summary>
 /// 利用Nid获取评论信息
 /// </summary>
 /// <param name="nid"></param>
 /// <returns></returns>
 public static List<CommentEntity> GetCommentsByNid(int nid)
 {
     DataBase db = new DataBase();
     DataSet rs = db.RunProcReturn("select * from tb_comment where nid=" + nid.ToString(), "tb_comment");
     List<CommentEntity> comments = new List<CommentEntity>();
     for (int i = 0; i < rs.Tables[0].Rows.Count; i++)
     {
         CommentEntity ce = new CommentEntity();
         ce.CommentTitle = rs.Tables[0].Rows[i]["commentTitle"].ToString();
         ce.UpTime = DateTime.Parse(rs.Tables[0].Rows[i]["upTime"].ToString());
         ce.Id = int.Parse(rs.Tables[0].Rows[i]["id"].ToString());
         ce.Agree = int.Parse(rs.Tables[0].Rows[i]["agree"].ToString());
         ce.DisAgree = int.Parse(rs.Tables[0].Rows[i]["disagree"].ToString());
         ce.ConText = rs.Tables[0].Rows[i]["Context"].ToString();
         ce.uid = int.Parse(rs.Tables[0].Rows[i]["uid"].ToString());
         ce.User = UserOperation.GetUser(ce.uid);
         comments.Add(ce);
     }
     return comments;
 }
 /// <summary>
 /// Create a new CommentEntity object.
 /// </summary>
 /// <param name="id">Initial value of Id.</param>
 /// <param name="blogEntryId">Initial value of BlogEntryId.</param>
 /// <param name="title">Initial value of Title.</param>
 /// <param name="name">Initial value of Name.</param>
 /// <param name="datePublished">Initial value of DatePublished.</param>
 /// <param name="text">Initial value of Text.</param>
 public static CommentEntity CreateCommentEntity(int id, int blogEntryId, string title, string name, global::System.DateTime datePublished, string text)
 {
     CommentEntity commentEntity = new CommentEntity();
     commentEntity.Id = id;
     commentEntity.BlogEntryId = blogEntryId;
     commentEntity.Title = title;
     commentEntity.Name = name;
     commentEntity.DatePublished = datePublished;
     commentEntity.Text = text;
     return commentEntity;
 }
 /// <summary>
 /// There are no comments for CommentEntitySet in the schema.
 /// </summary>
 public void AddToCommentEntitySet(CommentEntity commentEntity)
 {
     base.AddObject("CommentEntitySet", commentEntity);
 }
 public void CreateCommentEntity(CommentEntity comment)
 {
     uow.CommentRepository.Create(comment.ToDalComment());
     uow.Commit();
 }
Beispiel #39
0
 /// <summary>
 /// The add comment.
 /// </summary>
 /// <param name="commentEntity">
 /// The comment entity.
 /// </param>
 public void AddComment(CommentEntity commentEntity)
 {
     commentEntity.PostedTime = DateTime.Now;
     this.commentTable.InsertOnSubmit(commentEntity);
     this.Context.SubmitChanges();
 }
Beispiel #40
0
 public bool InsertComment(CommentEntity entity)
 {
     try
     {
         var paras = new SqlParameter[] { new SqlParameter("@Ucode",SqlDbType.NVarChar,30),
       new SqlParameter("@Evaluate", SqlDbType.Int),
       new SqlParameter("@CellPhone", SqlDbType.NVarChar,50),
       new SqlParameter("@Comment", SqlDbType.NVarChar,2000),
       new SqlParameter("@CreateTime", SqlDbType.DateTime),
       new SqlParameter("@Status", SqlDbType.Int),
       new SqlParameter("@CreateUser", SqlDbType.NVarChar,20),
         };
         paras[0].Value = entity.Ucode;
         paras[1].Value = entity.Evaluate;
         paras[2].Value = entity.CellPhone;
         paras[3].Value = entity.Comment;
         paras[4].Value = DateTime.Now;
         paras[5].Value = 1;
         paras[6].Value = "Aidaijia.API.CommentOrder.ashx";
         string sql = " Insert into D_DriverComment(Ucode,Evaluate,CellPhone,Comment,Create_Time,Create_User,Status)Values(@Ucode,@Evaluate,@CellPhone,@Comment,@CreateTime,@CreateUser,@Status)";
         //插入订单
         var value = helper.ExecuteCommand(sql, paras);
         if (value >= 0)
         {
             return true;
         }
         else
         {
             return false;
         }
     }
     catch (Exception ex)
     {
         LogControl.WriteError("InsertComment插入评论失败|Error:" + ex.Message);
         return false;
     }
 }