コード例 #1
0
        public List <ActivityComment> RetrieveComments(int activityId)
        {
            SqlCommand     command = null;
            SqlDataAdapter adapter = null;

            try
            {
                // Define command.
                command             = mDbConnection.CreateCommand();
                command.CommandText = "RetrieveComments";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@ActivityId", SqlDbType.Int).Value = activityId;

                // Execute command.
                adapter = new SqlDataAdapter(command);
                DataTable DtActivityComments = new DataTable();
                adapter.Fill(DtActivityComments);

                // Create a list.
                List <ActivityComment> ActivityCommentlst = null;
                if (DtActivityComments.Rows.Count > 0)
                {
                    ActivityCommentlst = new List <ActivityComment>();
                }

                // Iterate each row.
                foreach (DataRow row in DtActivityComments.Rows)
                {
                    ActivityComment Ac = new ActivityComment();
                    Ac.ActivityId       = Convert.ToInt32(row["ActivityId"].ToString());
                    Ac.ActivityStatusId = Convert.ToInt32(row["ActivityStatusId"].ToString());
                    Ac.Comment          = row["Comment"].ToString();
                    Ac.CreateDate       = Convert.ToDateTime(row["CreateDate"].ToString());
                    Ac.CreateUserId     = Convert.ToInt32(row["CreateUserId"].ToString());
                    Ac.CustomData.Add("Username", (string.IsNullOrEmpty(row["Username"].ToString())) ? null : row["Username"].ToString());
                    //Commented by saravanan on 07312012 release later
                    // Ac.CustomData.Add("ActivityStatus", (string.IsNullOrEmpty(row["ActivityStatus"].ToString())) ? null : row["ActivityStatus"].ToString());
                    // Add to list.
                    ActivityCommentlst.Add(Ac);
                }

                // Return the list.
                return(ActivityCommentlst);
            }
            catch { throw; }
            finally
            {
                // Dispose.
                if (adapter != null)
                {
                    adapter.Dispose();
                }
                if (command != null)
                {
                    command.Dispose();
                }
            }
        }
コード例 #2
0
        protected override bool CanExecuteInternal(object parameter)
        {
            ActivityComment comment = parameter as ActivityComment;

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

            return(comment.IsMine);
        }
コード例 #3
0
ファイル: CommentVM.cs プロジェクト: rmrxz/SchoolStartJourney
 public void MapToCm(ActivityComment cm)
 {
     cm.Name = Name;
     cm.Activity = Activity;
     cm.User = User;
     cm.CommentDataTime = CommentDataTime;
     cm.ParentGrade = ParentGrade;
     cm.Comment = Comment;
     cm.Hierarchy = Hierarchy;
     cm.AcceptUser = AcceptUser;
 }
コード例 #4
0
ファイル: CommentVM.cs プロジェクト: rmrxz/SchoolStartJourney
 public CommentVM(ActivityComment cm)
 {
     ID = cm.ID;
     Name = cm.Name;
     Activity = cm.Activity;
     User = cm.User;
     CommentDataTime = cm.CommentDataTime;
     ParentGrade = cm.ParentGrade;
     Hierarchy = cm.Hierarchy;
     Comment = cm.Comment;
     AcceptUser = cm.AcceptUser;
 }
コード例 #5
0
ファイル: AddComment.cs プロジェクト: OctavianM1/Pipe
            public async Task <AppComment> Handle(Command request, CancellationToken cancellationToken)
            {
                var activityComment = new ActivityComment
                {
                    Id              = Guid.NewGuid(),
                    UserId          = request.UserId,
                    ActivityId      = request.ActivityId,
                    Comment         = request.CommentBody,
                    DateTimeCreated = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                    DateTimeEdited  = DateTime.Now.ToString("dd/MM/yyyy HH:mm")
                };

                _context.ActivityComments.Add(activityComment);
                var success = await _context.SaveChangesAsync() > 0;

                if (success)
                {
                    AppUser user = _context.Users.Where(u => u.Id == activityComment.UserId).Select(u => new AppUser
                    {
                        Id                  = u.Id,
                        Name                = u.Name,
                        Email               = u.Email,
                        CountFollowers      = u.CountFollowers,
                        CountFollowing      = u.CountFollowing,
                        NumberOfActivities  = u.Activities.Count(),
                        CoverImageExtension = u.CoverImageExtension
                    }).FirstOrDefault();

                    var activityData = await _context.Activities.Where(a => a.Id == request.ActivityId)
                                       .Select(a => new { Title = a.Title, UserHostId = a.UserHostId })
                                       .FirstOrDefaultAsync();

                    var message = $"added new comment to your activity - {activityData.Title}";
                    await _sendNotification.Send(request.UserId, activityData.UserHostId, message);

                    return(new AppComment
                    {
                        Id = activityComment.Id,
                        User = user,
                        Comment = activityComment.Comment,
                        DateTimeCreated = activityComment.DateTimeCreated,
                        DateTimeEdited = activityComment.DateTimeEdited,
                        CommentLikeUsers = new List <AppUser>()
                    });
                }

                throw new Exception("Problem saving changes");
            }
コード例 #6
0
        public async Task <IActionResult> CommentTopic(int userId, int activityId, IncomingComment comment)
        {
            var commentToSave = new ActivityComment {
                Content = comment.Content,
                Side    = comment.Side
            };

            _activityRepo.CreateActivityComment(userId, activityId, commentToSave);

            if (await _mainRepo.SaveAll())
            {
                return(NoContent());
            }

            return(BadRequest("Failed"));
        }
コード例 #7
0
        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="id">活动id</param>
        /// <param name="ParentGrade">父级id</param>
        /// <returns></returns>
        public async Task <IActionResult> AddComment(Guid id, Guid?parentGrade, Guid acceptUserId, string comment)
        {
            var user = await _userManager.FindByIdAsync(User.Claims.FirstOrDefault().Value);

            if (user == null)
            {
                return(Json(new { isOK = false, message = "您还未登录,请登录后再评论" }));
            }
            if (id == Guid.Empty)
            {
                return(Json(new { isOK = false, message = "请选择评论的活动" }));
            }
            var activity = await _activityTermExtension.GetAll().Where(x => x.ID == id).FirstOrDefaultAsync();

            //评论的父级
            var parentGradeEntity = new ActivityComment();

            if (parentGrade != null && parentGrade != Guid.Empty)
            {
                parentGradeEntity = await _commonExtension.GetAll().Include(x => x.User).Where(x => x.ID == parentGrade).FirstOrDefaultAsync();

                if (parentGradeEntity == null)
                {
                    return(Json(new { isOK = false, message = "评论失败" }));
                }
            }
            var acceptUser = parentGradeEntity.User;

            if (acceptUserId != null && acceptUserId != Guid.Empty)
            {
                acceptUser = await _userManager.FindByIdAsync(acceptUserId.ToString());
            }
            _commonExtension.AddAndSave(new ActivityComment()
            {
                Name        = activity.Name,
                Activity    = activity,
                User        = user,
                AcceptUser  = acceptUser,
                ParentGrade = parentGrade,
                Comment     = comment,
                Hierarchy   = parentGrade != null && parentGrade != Guid.Empty ? 1 : 0
            });
            return(Json(new { isOK = true, message = "评论成功" }));
        }
コード例 #8
0
        protected override void PerformAction(object parameter)
        {
            ActivityComment comment = parameter as ActivityComment;

            ServiceProvider.FacebookService.RemoveComment(comment);
        }
コード例 #9
0
 public PhotoExplorerCommentNode(ActivityComment comment)
     : base(comment, string.Empty)
 {
     this.Comment = comment;
 }
コード例 #10
0
 public ActionResult submitComment(FormCollection form)
 {
     if (Session["user_id"] == null)
     {
         return(Redirect("~/login/index"));
     }
     else
     {
         SqlSugarClient db = new SqlSugarClient(
             new ConnectionConfig()
         {
             ConnectionString      = System.Web.Configuration.WebConfigurationManager.AppSettings["ConnectionString"],
             DbType                = DbType.Oracle,          //设置数据库类型
             IsAutoCloseConnection = true,                   //自动释放数据务,如果存在事务,在事务结束后释放
             InitKeyType           = InitKeyType.SystemTable //从实体特性中读取主键自增列信息
         });
         JObject isSuccess = new JObject();
         try
         {
             DateTime dt         = DateTime.Now;
             var      ActComData = new ActivityComment()
             {
                 activity_order_id = Convert.ToInt32(Request.Form["orderID"]),
                 grade             = Convert.ToDouble(Request.Form["rate"]),
                 user_id           = Session["user_id"].ToString(),
                 comment_text      = Request.Form["comment_content"],
                 times             = dt
             };
             if (Convert.ToInt16(Request.Form["accessWay"]) == 2)
             {
                 if (db.Insertable <HomestayComment>(ActComData).ExecuteCommand() == 1)
                 {
                     Session["message"] = "订单评价成功!";
                     return(Redirect("~/Admin"));
                 }
                 else
                 {
                     Session["message"] = "添加评论失败!";
                     return(Redirect("~/Admin"));
                 }
             }
             else if (Convert.ToInt16(Request.Form["accessWay"]) == 1)
             {
                 if (db.Insertable <ActivityComment>(ActComData).ExecuteCommand() == 1)
                 {
                     Session["message"] = "订单评价成功!";
                     return(Redirect("~/Admin"));
                 }
                 else
                 {
                     Session["message"] = "添加评论失败!";
                     return(Redirect("~/Admin"));
                 }
             }
             else
             {
                 Session["message"] = "参数错误!";
                 return(Redirect("~/Admin"));
             }
         }
         catch (Exception ex)
         {
             Session["message"] = "操作失败!";
             return(Redirect("~/Admin"));
         }
         finally {
         }
     }
 }
コード例 #11
0
 public void CreateActivityComment(int userId, int activityId, ActivityComment comment)
 {
     comment.User     = _context.Users.Find(userId);
     comment.Activity = _context.Activities.Find(activityId);
     _context.ActivityComments.Add(comment);
 }