public async Task <IActionResult> AddReplyCommentFromAdmin(int commentId, string replyDescription)
        {
            ReplyComment replyComment = new ReplyComment();

            replyComment.CommentId    = commentId;
            replyComment.Description  = replyDescription;
            replyComment.FullName     = HttpContext.User.Identity.Name;
            replyComment.IsFromAdmin  = true;
            replyComment.SubmitedDate = System.DateTime.Now;
            string username = HttpContext.User.Identity.Name;
            string userId   = await _userManager.Users
                              .AsNoTracking()
                              .Where(c => c.UserName.Equals(username))
                              .Select(c => c.Id).FirstOrDefaultAsync();

            replyComment.UserId   = userId;
            replyComment.FullName = await _userManager.Users
                                    .AsNoTracking()
                                    .Where(c => c.Id.Equals(userId))
                                    .Select(c => c.FullName).FirstOrDefaultAsync();

            await _db.ReplyComments.AddAsync(replyComment);

            await _db.SaveChangesAsync();

            return(PartialView(viewName: "_ReplyCommentFromAdmin", model: replyComment));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> AddReplyComment(int commentId, string description)
        {
            try
            {
                var replyComment = new ReplyComment();
                replyComment.CommentId   = commentId;
                replyComment.Description = description;
                string username = HttpContext.User.Identity.Name;
                string userId   = await _userManager.Users
                                  .AsNoTracking()
                                  .Where(c => c.UserName.Equals(username))
                                  .Select(c => c.Id).FirstOrDefaultAsync();

                replyComment.UserId   = userId;
                replyComment.FullName = await _userManager.Users
                                        .AsNoTracking()
                                        .Where(c => c.Id.Equals(userId))
                                        .Select(c => c.FullName).FirstOrDefaultAsync();

                await _db.ReplyComments.AddAsync(replyComment);

                await _db.SaveChangesAsync();

                return(Json(101));
            }
            catch (Exception)
            {
                return(Json(-1));
            }
        }
Ejemplo n.º 3
0
        public bool AddComment(ReplyComment comment)
        {
            using (var cmd = _conn.CreateCommand())
            {
                cmd.CommandText =
                    @"INSERT INTO Comments(
                          ID,
                          Theme,
                          Subforum,
                          Author,
                          Parent,
                          CreatedOn,
                          Content,
                          WasChanged,
                          WasLogicallyDeleted)
                      VALUES(NULL, @theme, @subforum, @author, @parent, @createdon, @content, 0, 0);";
                cmd.Parameters.AddWithValue("@theme", comment.ThemeTitle);
                cmd.Parameters.AddWithValue("@subforum", comment.SubforumName);
                cmd.Parameters.AddWithValue("@author", comment.AuthorName);
                cmd.Parameters.AddWithValue("@parent", comment.Parent);
                cmd.Parameters.AddWithValue("@createdon", comment.CreatedOn.ToString("yyyy-MM-dd"));
                cmd.Parameters.AddWithValue("@content", comment.Content);

                return(Execute(cmd));
            }
        }
Ejemplo n.º 4
0
        public bool ReplyComment(ReplyComment model)
        {
            bool rsBool = false;

            try
            {
                if (!string.IsNullOrEmpty(model.PageAccessToken))
                {
                    var url = $"{FBUrlApi}/{model.CommentId}/comments";
                    var rs  = HttpExtension.Instance.InvokePost <FBResponsed, FBPostComment>(url, new FBPostComment
                    {
                        access_token = model.PageAccessToken,
                        message      = model.Comment
                    }).Result;
                    if (rs != null)
                    {
                        rsBool = true;
                    }
                }
            }
            catch (Exception ex)
            {
                CoreLogger.Instance.Error(this.CreateMessageLog(ex.Message));
            }
            return(rsBool);
        }
Ejemplo n.º 5
0
        public ActionResult ReplyComment(int id)
        {
            if (LoggedUserName == null)
            {
                return(View("NotLoggedIn"));
            }

            ViewBag.Comment = Dao.GetComment((uint)id);

            if (Request.HttpMethod == "GET")
            {
                return(View());
            }

            var comment = new ReplyComment()
            {
                Parent       = (uint)id,
                AuthorName   = LoggedUserName,
                Content      = Request.Params["content"],
                CreatedOn    = DateTime.Now,
                SubforumName = ViewBag.Comment.SubforumName,
                ThemeTitle   = ViewBag.Comment.ThemeTitle
            };

            if (Dao.AddComment(comment))
            {
                ViewBag.Title = "Replying Successful";
            }
            else
            {
                ViewBag.Title = "Replying Failed";
            }

            return(View("ReplyResult"));
        }
        public ActionResult DeleteConfirmed(ReplyComment reply)
        {
            ReplyComment rep = db.ReplyComment.Find(Int32.Parse(reply.replycomment_id.ToString()));

            rep.replycomment_bin = false;
            db.SaveChanges();
            return(Redirect(admin_qlr));
        }
Ejemplo n.º 7
0
        public async Task <ReplyComment> Create(ReplyComment replycomment)
        {
            replycomment.ReplyTime     = DateTime.UtcNow;
            replycomment.ReplyTimeUnix = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            string id = await m_ReplyCommentRepositoryM.Create(replycomment);

            replycomment.Id = id;
            return(replycomment);
        }
Ejemplo n.º 8
0
 public static ReplyCommentResponse ToResponseReply(ReplyComment comment)
 {
     return(new ReplyCommentResponse()
     {
         Content = comment.Content,
         AuthorId = comment.AuthorId,
         ParentCommentId = comment.ParentId
     });
 }
        public Reply GetReply(string SysCmsInfoCommentId)
        {
            var reply = DbContext.GetById <SysCmsInfoComment>(SysCmsInfoCommentId);

            if (reply == null)
            {
                return(new Reply());
            }
            var comment     = DbContext.GetById <SysCmsInfoComment>(reply.ToCommentId);
            var commentUser = DbContext.GetById <SysUser>(comment.SysUserId);
            var replyUser   = DbContext.GetById <SysUser>(reply.SysUserId);

            var formartReplyComment = new ReplyComment()
            {
                article     = comment.SysCmsInfoId,
                commentDate = comment.CommentTime.ToDateTimeString(),
                commentId   = comment.SysCmsInfoCommentId,
                content     = comment.Comment,
                site        = comment.Address,
                user        = new CommentUser
                {
                    commentNum       = 0,
                    headPortrait     = commentUser?.Avatar,
                    latelyLoginTime  = comment.CommentTime.ToDateTimeString(),
                    registrationDate = comment.CommentTime.ToDateTimeString(),
                    nickname         = commentUser.NikeName,
                    sex      = commentUser.Sex,
                    userId   = commentUser.SysUserId,//博主的userId='admin'
                    userType = commentUser.UserType
                },
            };
            var formartRepaly = new Reply
            {
                replyId   = reply.SysCmsInfoCommentId,
                comment   = formartReplyComment,
                content   = reply.Comment,
                replyDate = reply.CommentTime.ToDateTimeString(),
                site      = reply.Address,
                user      = new CommentUser
                {
                    commentNum       = 0,
                    headPortrait     = replyUser?.Avatar,
                    latelyLoginTime  = reply.CommentTime.ToDateTimeString(),
                    registrationDate = reply.CommentTime.ToDateTimeString(),
                    nickname         = replyUser.NikeName,
                    sex      = replyUser.Sex,
                    userId   = replyUser.SysUserId,//博主的userId='admin'
                    userType = replyUser.UserType
                },
            };

            return(formartRepaly);
        }
Ejemplo n.º 10
0
        public ActionResult ReplyComment([Bind(Include = "replycomment_id,replycomment_content,comment_id,user_id,product_id,seller_id,replycomment_spam,replycomment_datecreated,replycomment_bin")] ReplyComment replyComment, int?id)
        {
            User us = (User)Session["user"];

            replyComment.user_id                  = us.user_id;
            replyComment.product_id               = Int32.Parse(Session["product"].ToString());
            replyComment.replycomment_spam        = true;
            replyComment.replycomment_bin         = true;
            replyComment.replycomment_datecreated = DateTime.Now;
            db.ReplyComment.Add(replyComment);
            db.SaveChanges();
            return(Redirect(detail + id));
        }
 public ActionResult Edit([Bind(Include = "replycomment_id,replycomment_content,comment_id,user_id,product_id,seller_id,replycomment_spam,replycomment_datecreated,replycomment_bin")] ReplyComment replyComment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(replyComment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.comment_id = new SelectList(db.Comment, "comment_id", "comment_content", replyComment.comment_id);
     ViewBag.product_id = new SelectList(db.Product, "product_id", "product_name", replyComment.product_id);
     ViewBag.seller_id  = new SelectList(db.Seller, "seller_id", "seller_pass", replyComment.seller_id);
     ViewBag.user_id    = new SelectList(db.User, "user_id", "user_pass", replyComment.user_id);
     return(View(replyComment));
 }
        // GET: Admin/ReplyComments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReplyComment replyComment = db.ReplyComment.Find(id);

            if (replyComment == null)
            {
                return(HttpNotFound());
            }
            return(View(replyComment));
        }
Ejemplo n.º 13
0
 public bool Create(ReplyComment replyComment)
 {
     try
     {
         _context.Add(replyComment);
         _context.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.Write(e.StackTrace);
         return(false);
     }
 }
        public ActionResult ReplyComment(int id, int idPost, string replyComment)
        {
            var id_doctor = Convert.ToInt32(Session["Id"]);
            // Add post
            ReplyComment replyComments = new ReplyComment()
            {
                CommentContent = replyComment,
                CommentDate    = DateTime.Now,
                Comment_ID     = id,
                Doctor_ID      = id_doctor,
            };

            db.ReplyComments.Add(replyComments);
            db.SaveChanges();
            return(RedirectToAction("DetailPost/" + idPost, "Post"));
        }
 public ActionResult Create([Bind(Include = "replycomment_id,replycomment_content,comment_id,user_id,product_id,seller_id,replycomment_spam,replycomment_datecreated,replycomment_bin")] ReplyComment replyComment)
 {
     if (replyComment == null)
     {
         Response.StatusCode = 404;
         return(null);
     }
     else
     {
         db.ReplyComment.Add(replyComment);
         replyComment.replycomment_datecreated = DateTime.Now;
         replyComment.replycomment_spam        = true;
         replyComment.replycomment_bin         = true;
         db.SaveChanges();
         return(Redirect(admin_qlr));
     }
 }
        // GET: Admin/ReplyComments/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReplyComment replyComment = db.ReplyComment.Find(id);

            if (replyComment == null)
            {
                return(HttpNotFound());
            }
            ViewBag.comment_id = new SelectList(db.Comment, "comment_id", "comment_content", replyComment.comment_id);
            ViewBag.product_id = new SelectList(db.Product, "product_id", "product_name", replyComment.product_id);
            ViewBag.seller_id  = new SelectList(db.Seller, "seller_id", "seller_pass", replyComment.seller_id);
            ViewBag.user_id    = new SelectList(db.User, "user_id", "user_pass", replyComment.user_id);
            return(View(replyComment));
        }
Ejemplo n.º 17
0
        public async Task <ReportViewModel> ReplyReport(CreateReplyReportRequest request)
        {
            User currentUser = Feature.CurrentUser(httpContextAccessor, userRepository);

            ReplyComment comment = await replyCommentRepository.GetByIdAsync(ObjectId.Parse(request.ReplyId));

            Report data = new Report()
            {
                AuthorId   = currentUser.OId,
                Reason     = request.Reason.ToList(),
                ObjectId   = request.ReplyId,
                ObjectType = Feature.GetTypeName(comment)
            };

            await fcmRepository.AddToGroup(
                new AddUserToGroupRequest
            {
                GroupName = comment.AuthorId,
                Type      = Feature.GetTypeName(currentUser),
                UserIds   = new List <string> {
                    comment.AuthorId
                }
            }
                );

            await reportRepository.AddAsync(data);

            var notificationDetail = new Noftication()
            {
                AuthorId        = currentUser.OId,
                OwnerId         = currentUser.OId,
                ObjectId        = comment.OId,
                ObjectThumbnail = comment.Content
            };

            //Bài viết của bạn đã bị báo cáo.
            await fcmRepository.PushNotify(comment.AuthorId, notificationDetail, NotificationContent.CommentReportNotification, "Phản hồi của bạn đã bị báo cáo. ");


            return(mapper.Map <ReportViewModel>(data));
        }
Ejemplo n.º 18
0
 public bool Delete(int?id)
 {
     try
     {
         ReplyComment replyComment = _context.ReplyComments.Find(id);
         if (replyComment != null)
         {
             _context.ReplyComments.Remove(replyComment);
             _context.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         Console.Write(e.StackTrace);
         return(false);
     }
 }
Ejemplo n.º 19
0
        public bool saveComment(int id, String content, String account)
        {
            bool  result = false;
            Reply reply  = null;
            User  user   = null;
            Owner owner  = null;

            if (replyDao.Select(id, null, null, null, null, 0).Count > 0)
            {
                reply = replyDao.Select(id, null, null, null, null, 0)[0];
            }
            else
            {
                return(result);
            }
            owner = reply.owner;
            if (userDao.Select(null, account, null, null, null, null, null, null, null, null, null, null, null).Count > 0)
            {
                user = userDao.Select(null, account, null, null, null, null, null, null, null, null, null, null, null)[0];
            }
            else
            {
                return(result);
            }
            ReplyComment replycomment = new ReplyComment();

            replycomment.Replier      = reply;
            replycomment.ReplyContent = content;
            replycomment.time         = DateTime.Now;
            replycomment.User         = user;
            owner.LastReplyTime       = replycomment.time;
            if (replyCommentDao.Create(replycomment) && ownerDao.Edit(owner))
            {
                result = true;
            }
            return(result);
        }
Ejemplo n.º 20
0
        public async Task <IEnumerable <ReportViewModel> > Approve(IEnumerable <string> ids)
        {
            List <Report> dataToApprove = new List <Report>();

            foreach (string item in ids)
            {
                Report rp = await reportRepository.GetByIdAsync(ObjectId.Parse(item));

                if (rp != null)
                {
                    dataToApprove.Add(rp);
                }
            }

            User currentUser = Feature.CurrentUser(httpContextAccessor, userRepository);

            foreach (Report item in dataToApprove)
            {
                #region Find the same object

                var reportBuilders = Builders <Report> .Filter;
                var reportFilter   = reportBuilders.Eq("object_id", item.ObjectId);
                var sameObjects    = (await reportRepository.FindListAsync(reportFilter)).ToList();
                sameObjects.ForEach(async x =>
                {
                    x.IsApproved   = true;
                    x.ModifiedDate = DateTime.Now;
                    x.ApprovedBy   = currentUser.OId;
                    x.ApproveDate  = DateTime.Now;
                    await reportRepository.UpdateAsync(x, x.Id);
                });

                #endregion

                if (item.ObjectType.Contains("Post"))
                {
                    Post post = await postRepository.GetByIdAsync(ObjectId.Parse(item.ObjectId));

                    post.Status       = ItemStatus.Deleted;
                    post.ModifiedDate = DateTime.Now;
                    await postRepository.UpdateAsync(post, post.Id);

                    var user = await userRepository.GetByIdAsync(ObjectId.Parse(post.AuthorId));

                    if (user == null)
                    {
                        throw new Exception("Không tìm thấy người dùng. ");
                    }

                    var notificationDetail = new Noftication()
                    {
                        AuthorId        = currentUser.OId,
                        OwnerId         = currentUser.OId,
                        ObjectId        = post.OId,
                        ObjectThumbnail = post.Title
                    };

                    await fcmRepository.PushNotify(post.AuthorId,
                                                   notificationDetail,
                                                   NotificationContent.ApprovePostReportNotification,
                                                   $"Bài viết của bạn đã bị xóa bởi quản trị viên. ");

                    //Báo cáo của bạn đã được duyệt.
                    await fcmRepository.PushNotify(item.AuthorId,
                                                   notificationDetail,
                                                   NotificationContent.ApprovePostReportNotification,
                                                   $"Báo cáo của bạn về bài viết của{user.FirstName} {user.LastName} đã được xem xét. ");
                }
                else
                if (item.ObjectType.Contains("ReplyComment"))
                {
                    ReplyComment replyComment = await replyCommentRepository.GetByIdAsync(ObjectId.Parse(item.ObjectId));

                    replyComment.Status       = ItemStatus.Deleted;
                    replyComment.ModifiedDate = DateTime.Now;
                    await replyCommentRepository.UpdateAsync(replyComment, replyComment.Id);

                    var user = await userRepository.GetByIdAsync(ObjectId.Parse(replyComment.AuthorId));

                    if (user == null)
                    {
                        throw new Exception("Không tìm thấy người dùng. ");
                    }

                    var notificationDetail = new Noftication()
                    {
                        AuthorId        = currentUser.OId,
                        OwnerId         = currentUser.OId,
                        ObjectId        = replyComment.OId,
                        ObjectThumbnail = replyComment.Content
                    };

                    //Báo cáo của bạn đã được duyệt.
                    await fcmRepository.PushNotify(item.AuthorId,
                                                   notificationDetail,
                                                   NotificationContent.ApproveReplyReportNotification,
                                                   $"Báo cáo của bạn về phản hồi của {user.FirstName} {user.LastName} đã được xem xét. ");

                    await fcmRepository.PushNotify(replyComment.AuthorId,
                                                   notificationDetail,
                                                   NotificationContent.ApproveReplyReportNotification,
                                                   $"Phản hồi của bạn đã bị xóa bởi quản trị viên. ");
                }
                else
                if (item.ObjectType.Contains("Comment"))
                {
                    Comment comment = await commentRepository.GetByIdAsync(ObjectId.Parse(item.ObjectId));

                    comment.Status       = ItemStatus.Deleted;
                    comment.ModifiedDate = DateTime.Now;
                    await commentRepository.UpdateAsync(comment, comment.Id);

                    var user = await userRepository.GetByIdAsync(ObjectId.Parse(comment.AuthorId));

                    if (user == null)
                    {
                        throw new Exception("Không tìm thấy người dùng. ");
                    }

                    var notificationDetail = new Noftication()
                    {
                        AuthorId        = currentUser.OId,
                        OwnerId         = currentUser.OId,
                        ObjectId        = comment.OId,
                        ObjectThumbnail = comment.Content
                    };

                    //Báo cáo của bạn đã được duyệt.
                    await fcmRepository.PushNotify(item.AuthorId,
                                                   notificationDetail,
                                                   NotificationContent.ApproveCommentReportNotification,
                                                   $"Báo cáo của bạn về bình luận của {user.FirstName} {user.LastName} đã được xem xét.");

                    await fcmRepository.PushNotify(comment.AuthorId,
                                                   notificationDetail,
                                                   NotificationContent.ApproveCommentReportNotification,
                                                   $"Bình luận của bạn đã bị xóa bởi quản trị viên. ");
                }
            }
            return(mapper.Map <IEnumerable <ReportViewModel> >(dataToApprove));
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 增加回复
 /// </summary>
 /// <param name="addReplyComment"></param>
 /// <returns></returns>
 public bool AddReplyComment(ReplyComment addReplyComment)
 {
     _myDbContext.ReplyCommentRepository.Add(addReplyComment);
     return(_myDbContext.SaveChanges() > 0);
 }
Ejemplo n.º 22
0
        public async Task <IActionResult> Create([FromBody] ReplyComment model)
        {
            ReplyComment replycomment = await m_ReplyCommentBusiness.Create(model);

            return(Json(replycomment));
        }
Ejemplo n.º 23
0
 public async Task <bool> Update(ReplyComment replycomment)
 {
     return(await m_ReplyCommentRepositoryM.Update(replycomment));
 }
Ejemplo n.º 24
0
        public async Task <IActionResult> Update([FromBody] ReplyComment model)
        {
            bool result = await m_ReplyCommentBusiness.Update(model);

            return(Json(result));
        }