コード例 #1
0
        public async Task <ActionResult> CommentReply(ReplyVM commentreply)
        {
            int sessionUserId = Convert.ToInt32(Session["UserId"]);

            //validation
            if (sessionUserId == 0)
            {
                return(RedirectToAction("Login", "Account")); //if not login
            }

            if (ModelState.IsValid) //validation
            {
                Reply reply = new Reply()
                {
                    userInput = commentreply.Reply,
                    CommentId = commentreply.CommentId, // must be hidden field
                    UserId    = sessionUserId,
                    CreatedOn = DateTime.Now
                };
                _db.Replies.Add(reply);
                await _db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View("Index")); //optional
        }
コード例 #2
0
        public IActionResult PostReply(ReplyVM obj)
        {
            var Id       = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var Name     = User.FindFirstValue(ClaimTypes.Name);
            var user     = _context.Users.Where(u => u.Id == Id).SingleOrDefault();
            var NameFull = user.Name;

            Reply record = new Reply();

            {
                record.Text      = obj.Reply;
                record.DateTime  = System.DateTime.Now;
                record.UserId    = Id;
                record.PostId    = obj.FID;
                record.Name      = Name;
                record.NameFull  = NameFull;
                record.Messenger = user.Messenger;
                record.City      = user.City;
            }

            _context.Replies.Add(record);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
コード例 #3
0
ファイル: Reply.cs プロジェクト: sansob/ProMa2
 public void Update(int id, ReplyVM replyVM)
 {
     this.ReplyFrom  = replyVM.ReplyFrom;
     this.Message    = replyVM.Message;
     this.Date       = replyVM.Date;
     this.UpdateDate = DateTimeOffset.Now.ToLocalTime();
 }
コード例 #4
0
        public bool Insert(ReplyVM replyVM)
        {
            var push      = new Reply(replyVM);
            var getTicket = applicationContext.Tickets.Find(replyVM.Ticket_Id);

            if (getTicket != null)
            {
                push.Ticket = getTicket;
                applicationContext.Replies.Add(push);
                var result = applicationContext.SaveChanges();
                if (result > 0)
                {
                    status = true;
                    return(status);
                }
                else
                {
                    return(status);
                }
            }
            else
            {
                return(status);
            }
        }
コード例 #5
0
        public async Task <IActionResult> Create(int id)
        {
            var post  = _postService.GetById(id);
            var forum = _forumService.GetById(post.Forum.Id);
            var user  = await _userManager.FindByNameAsync(User.Identity.Name);

            var model = new ReplyVM
            {
                PostContent = post.Content,
                PostTitle   = post.Title,
                PostId      = post.Id,

                ForumName     = forum.Title,
                ForumId       = forum.Id,
                ForumImageUrl = forum.Image,

                AuthorName     = User.Identity.Name,
                AuthorImageUrl = user.UserImage,
                AuthorId       = user.Id,
                AuthorRating   = user.Rating,
                IsAuthorAdmin  = user.IsAdmin,

                Date = DateTime.Now
            };

            return(View(model));
        }
コード例 #6
0
ファイル: Reply.cs プロジェクト: sansob/ProMa2
 public Reply(ReplyVM replyVM)
 {
     this.ReplyFrom  = replyVM.ReplyFrom;
     this.Message    = replyVM.Message;
     this.Date       = replyVM.Date;
     this.CreateDate = DateTimeOffset.Now.ToLocalTime();
 }
コード例 #7
0
        public IActionResult Reply(int postId)
        {
            var replyVM = new ReplyVM {
                PostID = postId
            };

            return(View(replyVM));
        }
コード例 #8
0
ファイル: RepliesController.cs プロジェクト: sansob/ProMa2
        // POST: api/Replies

        public HttpResponseMessage InsertReplies(ReplyVM replyVM)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Bad Request");
            var result  = _iReplyService.Insert(replyVM);

            if (result)
            {
                message = Request.CreateResponse(HttpStatusCode.OK, replyVM);
            }
            return(message);
        }
コード例 #9
0
ファイル: RepliesController.cs プロジェクト: sansob/ProMa2
        // PUT: api/Replies/5
        public HttpResponseMessage PutUpdateReplies(int id, ReplyVM replyVM)
        {
            var message = Request.CreateErrorResponse(HttpStatusCode.NotModified, "Not Modified");
            var result  = _iReplyService.Update(id, replyVM);

            if (result)
            {
                message = Request.CreateResponse(HttpStatusCode.OK, replyVM);
            }
            return(message);
        }
コード例 #10
0
 public bool Update(int id, ReplyVM replyVM)
 {
     if (string.IsNullOrWhiteSpace(replyVM.Id.ToString()) && string.IsNullOrWhiteSpace(replyVM.Ticket_Id.ToString()))
     {
         return(status);
     }
     else
     {
         return(_iReplyRepository.Update(id, replyVM));
     }
 }
コード例 #11
0
 public bool Insert(ReplyVM replyVM)
 {
     if (string.IsNullOrWhiteSpace(replyVM.ReplyFrom.ToString()) && string.IsNullOrWhiteSpace(replyVM.Ticket_Id.ToString()))
     {
         return(status);
     }
     else
     {
         return(_iReplyRepository.Insert(replyVM));
     }
 }
コード例 #12
0
        public async Task <IActionResult> AddReply(ReplyVM model)
        {
            var userId = _userManager.GetUserId(User);
            var user   = await _userManager.FindByIdAsync(userId);

            var reply = BuildReply(model, user);
            await _postService.AddReply(reply);

            await _userService.BumpRating(userId, typeof(Reply));

            return(RedirectToAction("Index", "Post", new { id = model.PostId }));
        }
コード例 #13
0
        private Reply BuildReply(ReplyVM reply, ApplicationUser user)
        {
            var now  = DateTime.Now;
            var post = _postService.GetById(reply.PostId);

            return(new Reply
            {
                Post = post,
                Message = reply.ReplyContent,
                DateCreated = now,
                User = user
            });
        }
コード例 #14
0
ファイル: ReplyController.cs プロジェクト: hoatv/ims2019
        public IActionResult Index(int?page)
        {
            //List<ReplyModel> listReply = new List<ReplyModel>();
            //listReply = replyDAL.GetAllReply().ToList();
            //return View(listReply);
            ReplyVM replyVM    = new ReplyVM();
            int     pageSize   = 10;
            int     pageNumber = page ?? 1;
            int     totalCount;

            replyVM.listReply      = replyDAL.GetAllReply(out totalCount).ToPagedList(pageNumber, pageSize);
            replyVM.PagingMetaData = new StaticPagedList <ReplyModel>(replyVM.listReply, pageNumber + 1, pageSize, totalCount).GetMetaData();
            return(View(replyVM));
        }
コード例 #15
0
        public async Task <IActionResult> AddComment(string data)
        {
            User user = await _userManager.GetUserAsync(User);

            string[] reply = data.Split('"');
            if (reply[7] == "")
            {
                TempData["blankForm"] = "Xahiş edirik formu boş saxlamayın";
                return(Content("No"));
            }
            if (reply.Length < 11)
            {
                Comment comment = new Comment
                {
                    UserId    = user.Id,
                    ArticleId = Int32.Parse(reply[3]),
                    Text      = reply[7],
                    Date      = DateTime.Now
                };
                _db.Comments.Add(comment);
            }
            else
            {
                RepliedComment rComment = new RepliedComment
                {
                    UserId    = user.Id,
                    Text      = reply[7],
                    Date      = DateTime.Now,
                    CommentId = Int32.Parse(reply[11]),
                    //ArticleId = Int32.Parse(reply[3])
                };

                _db.RepliedComments.Add(rComment);
            }


            await _db.SaveChangesAsync();

            ReplyVM replyVM = new ReplyVM
            {
                Comments        = _db.Comments.Include(c => c.User).Where(c => c.Article == _db.Articles.Where(s => s.Id == Int32.Parse(reply[3])).FirstOrDefault()),
                RepliedComments = _db.RepliedComments.Include(r => r.User).Where(c => c.Comment.Article == _db.Articles.Where(s => s.Id == Int32.Parse(reply[3])).FirstOrDefault())
            };

            return(Content("Okay"));
        }
コード例 #16
0
        public ActionResult Reply(int Id)
        {
            var thread = _context.Threads.First(x => x.MessageThreadId == Id)
                         .Messages.OrderBy(x => x.Created).ToList();

            if (thread != null)
            {
                ReplyVM vm = new ReplyVM()
                {
                    Messages        = thread,
                    Subject         = thread.FirstOrDefault().Subject,
                    MessageThreadId = Id
                };
                return(View(vm));
            }

            return(RedirectToAction("Index", "Home"));
        }
コード例 #17
0
        public bool Update(int id, ReplyVM replyVM)
        {
            var pull      = Get(id);
            var getTicket = applicationContext.Tickets.Find(replyVM.Ticket_Id);

            pull.Ticket = getTicket;
            pull.Update(id, replyVM);
            applicationContext.Entry(pull).State = EntityState.Modified;
            var result = applicationContext.SaveChanges();

            if (result > 0)
            {
                status = true;
                return(status);
            }
            else
            {
                return(status);
            }
        }
コード例 #18
0
        public IActionResult Reply(ReplyVM replyVM, NewsVM model)
        {
            Comment comment = new Comment();
            User    user    = new User();

            user = _newscontext.Users.Where(q => q.EMail == replyVM.useremail).FirstOrDefault();
            News news = _newscontext.News.FirstOrDefault(x => x.ID == model.ID);

            model.Title = news.Title;

            comment.UserId   = user.ID;
            comment.ParentId = replyVM.parentid;
            comment.NewsId   = model.ID;
            comment.Content  = replyVM.replycomment;

            _newscontext.Comments.Add(comment);
            _newscontext.SaveChanges();
            string url = "/haber/" + model.ID + "/" + UrlHelpers.FriendlyUrl(model.Title);

            return(Redirect(url));
        }
コード例 #19
0
        public RedirectToActionResult Reply(ReplyVM replyVM)
        {
            // Comment is the domain model
            var reply = new Reply {
                ReplyText = replyVM.ReplyText
            };

            reply.Replier   = userManager.GetUserAsync(User).Result;
            reply.ReplyDate = DateTime.Now;

            // Retrieve the review that this comment is for
            var post = (from r in repo.Forum
                        where r.PostId == replyVM.PostID
                        select r).First <Post>();

            // Store the review with the comment in the database
            post.Replies.Add(reply);
            repo.UpdatePost(post);

            return(RedirectToAction("Forum"));
        }
コード例 #20
0
        public ActionResult PostReply(ReplyVM obj)
        {
            int userId = Convert.ToInt32(Session["UserId"]);

            //Textbox i reply eshte bosh
            if (string.IsNullOrEmpty(obj.Reply))
            {
                return(RedirectToAction("Index"));
            }

            //Shtimi i reply
            Reply r = new Reply();

            r.Text      = obj.Reply;
            r.CommentId = obj.CID;
            r.UserId    = userId;
            r.CreatedOn = DateTime.Now;
            db.Reply.Add(r);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #21
0
ファイル: ReplyController.cs プロジェクト: hoatv/ims2019
        public IActionResult _Detail(string id, string actionType)
        {
            ReplyVM    replyVM    = new ReplyVM();
            ReplyModel replyModel = new ReplyModel();

            if (actionType.ToLower().Equals("insert"))
            {
                // Insert
                replyVM.actionType            = "insert";
                replyVM.listClauseIssueModels = clauseIssueDAL.GetAllClauseIssue();
                replyVM.listIssue             = issueDAL.GetAllIssues();
                replyVM.listClauseIssueModels = clauseIssueDAL.GetAllClauseIssue();
                //replyVM.listIssue =
                //replyVM.listClauseIssue = clauseIssueDAL.GetAllClauseIssue().ToList();
                //replyVM.listClause = clauseDAL.GetAllClause().ToList();
                //GetAllClause
            }
            else
            {
                // Update
                //clauseVM.actionType = "Update";
                //clauseVM.clauseModel = clauseDAL.GetClauseById(id);
                //clauseVM.listDocument = documentDAL.GetAllDocuments();
                //clauseVM.listVersion = menuDAL.GetAllVersion();
                //clauseModel = clauseDAL.GetDocumentByID(id);
                ////documentVM.listDocument = documentDAL.GetAllDocuments().ToList();
                //documentVM.listDocType = menuDAL.GetAllDocType();
                //documentVM.listVersion = menuDAL.GetAllVersion();
                //documentVM.listDocStatus = menuDAL.GetAllDocStatus();
                //documentVM.documentModel = document;
                replyVM.actionType            = "update";
                replyVM.replyModel            = replyDAL.GetReplyByID(id);
                replyVM.listClauseIssueModels = clauseIssueDAL.GetAllClauseIssue();
                replyVM.listIssue             = issueDAL.GetAllIssues();
            }
            return(PartialView("_Detail", replyVM));
        }