public ActionResult TaskDetails(TaskModel taskModel)
        {
            BackendlessUser user = Backendless.UserService.CurrentUser;

            if (user == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            comRepo.AddComment((string)TempData["TaskID"], (string)user.Properties["name"],
                               (string)user.Properties["surname"], taskModel.Comment, true);

            return(RedirectToAction("TaskDetails", taskModel.objectId));
        }
Exemple #2
0
        public ActionResult Index(FormCollection formData)
        {
            String strComment = formData["CommentText"];

            if (!String.IsNullOrEmpty(strComment))
            {
                Comment           c   = new Comment( );
                CommentRepository rep = new CommentRepository( );

                c.CommentText = strComment;
                String strUser = System.Security.Principal.WindowsIdentity.GetCurrent( ).Name;
                if (!String.IsNullOrEmpty(strUser))
                {
                    int slashPos = strUser.IndexOf("\\");
                    if (slashPos != -1)
                    {
                        strUser = strUser.Substring(slashPos + 1);
                    }
                    c.UserName = strUser;

                    rep.AddComment(c);
                }
                else
                {
                    c.UserName = "******";
                }
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("CommentText", "Kjánaprik. Ætlarðu að setja inn tóma athugasemd?");
                return(Index( ));
            }
        }
        public ActionResult Reply(string subject, string comment, string datasetId, string parentType, string container, string origRowKey)
        {
            var result = new Comment
            {
                Subject         = subject,
                Body            = comment,
                Posted          = DateTime.Now,
                Type            = "General Comment (no reply required)",
                Status          = "N/A",
                Notify          = false,
                ParentName      = datasetId,
                ParentType      = parentType,
                Author          = User.Identity.Name,
                ParentContainer = container
            };

            CommentRepository.AddComment(result);

            Comment original = CommentRepository.GetComment(origRowKey);

            original.Status = "Replied";
            CommentRepository.Update(original);

            return(Json("Replied", JsonRequestBehavior.AllowGet));
        }
 public bool AddComment(Comment comment)
 {
     return(_commentRepository.AddComment(new DataAccess.Entities.Comment
     {
         CommentId = Guid.Parse(comment.CommentId),
         Text = comment.Text,
         PostPostId = Guid.Parse(comment.PostPostId)
     }));
 }
Exemple #5
0
 public bool AddComment(Comment comment)
 {
     return(_commentRepository.AddComment(new gRPC_si_EF_DATA.Entities.Comment
     {
         CommentId = Guid.Parse(comment.CommentId),
         Text = comment.Text,
         PostPostId = Guid.Parse(comment.PostPostId)
     }));
 }
Exemple #6
0
        public async Task <IActionResult> Post(Comment comment)
        {
            var user = await GetCurrentUserAsync();

            comment.UserProfileId = user.Id;
            _commentRepository.AddComment(comment);

            return(Ok(comment));
        }
Exemple #7
0
        public IActionResult CreateComment([FromBody] JObject data)
        {
            string content = data["comment"].ToObject <string>();
            int    postId  = data["postId"].ToObject <int>();
            int    userId  = data["userId"].ToObject <int>();

            Comment comment = new Comment(content, postId, userId);

            return(Ok(_commentRepository.AddComment(comment)));
        }
        public ActionResult PostComment(int problemId, string commentText)
        {
            var     userId     = (int)Session["UserId"];
            Comment newComment = new Comment(commentText, 0, userId, problemId);

            _commentRepo.AddComment(newComment);
            ProblemModel pm = new ProblemModel();

            pm.Getproblem(problemId);
            return(RedirectToAction("Detail", new { id = problemId }));
        }
Exemple #9
0
 public ActionResult Comment(string comment, int postId)
 {
     this.postRepository    = new PostRepository(db);
     this.commentRepository = new CommentRepository(db);
     if (SessionHelper.User != null)
     {
         commentRepository.AddComment(postId, comment);
     }
     return(View("Index",
                 new DetailedPostViewModel(this.postRepository.GetPublicPostById(postId))));
 }
 public ActionResult Create(Comment comment)
 {
     try
     {
         comment.CreateDateTime = DateAndTime.Now;
         comment.UserProfileId  = GetCurrentUserProfileId();
         _commentRepo.AddComment(comment);
         return(RedirectToAction("Index", new { id = comment.PostId }));
     }
     catch
     {
         return(View(comment));
     }
 }
Exemple #11
0
        public JsonResult addNewComment(commentDTO comment)
        {
            try
            {
                var model = repo.AddComment(comment);

                return(Json(new { error = false, result = model }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                //Handle Error here..
            }

            return(Json(new { error = true }, JsonRequestBehavior.AllowGet));
        }
Exemple #12
0
        public void CreateComment(Int64 billId, string cmtbody, string subject, Int64 empId)
        {
            Comment _cmt = new Comment()
            {
                Emp_ID      = empId,
                TimeStamp   = DateTime.Now,
                Bill_ID     = billId,
                Cmt_Body    = cmtbody,
                Cmt_Subject = subject
            };
            CommentRepository cmt = new CommentRepository(_context);

            cmt.AddComment(_cmt);
            return;
        }
        public ActionResult Create(Comment comment)
        {
            try
            {
                comment.CreateDateTime = DateAndTime.Now;
                _commentRepository.AddComment(comment);

                return(RedirectToAction("Index", new { PostId = comment.PostId }));
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
                return(View(comment));
            }
        }
Exemple #14
0
 public JObject AddComment(CommentModel comment, string UserId, string CommentId)
 {
     if (UserId == null || comment.PostId == null || comment.Message == null || comment.Message == "")
     {
         return(JObject.Parse("{ \"message\" : \"Put all data please!\", \"post\": " + JObject.FromObject(comment) + ",  \"status\" : \"400\" }"));
     }
     else
     {
         object response = _commentRepository.AddComment(comment, UserId, CommentId);
         if (response == null)
         {
             return(JObject.Parse("{ \"message\" : \"User or Post doesn't exist! use a valid user or post id\",  \"status\" : \"404\" }"));
         }
         return(JObject.Parse("{ \"message\" : \"Comment added successfully!\", \"comment\" : " + JObject.FromObject(comment) + ", \"status\" : \"200\" }"));
     }
 }
Exemple #15
0
 public ActionResult Create(CommentIndexViewModel vm, int id)
 {
     try
     {
         vm.Comment.UserProfileId  = GetCurrentUserProfileId();
         vm.Comment.PostId         = id;
         vm.PostComments           = _commentRepo.GetCommentsByPostId(id);
         vm.Comment.CreateDateTime = DateTime.Now;
         _commentRepo.AddComment(vm.Comment);
         return(RedirectToAction("Index", new { id = id }));
     }
     catch (Exception ex)
     {
         return(View(vm));
     }
 }
Exemple #16
0
        public bool AddComment(Comment model)
        {
            bool rs = false;

            try
            {
                if (repository.AddComment(model) > 0)
                {
                    rs = true;
                }
            }
            catch (Exception ex)
            {
                CoreLogger.Instance.Error(this.CreateMessageLog(ex.Message));
            }
            return(rs);
        }
        public void AddComment(string userEmail, string documentId, Comment comment)
        {
            Guid docId = Guid.Parse(documentId);

            ValidateUser(userEmail);
            ValidateDocument(docId);
            ValidateRating(comment.Rating);

            User     user     = UserRepository.GetByEmail(userEmail);
            Document document = DocumentRepository.GetById(docId);

            comment.Id        = Guid.NewGuid();
            comment.Commenter = user;
            comment.Document  = document;

            CommentRepository.AddComment(comment);
        }
Exemple #18
0
        public IActionResult Comment(Comment newcomment)
        {
            List <string> temp_errors = new List <string>();

            if (ModelState.IsValid)
            {
                Console.WriteLine("Comment is Successfully added");
                commentFactory.AddComment(newcomment);
                return(RedirectToAction("Dashboard"));
            }
            else
            {
                temp_errors.Add("Comment Strength is weak");
                TempData["errors"] = temp_errors;
                return(RedirectToAction("Dashboard"));
            }
        }
        public ActionResult Add(string name, string subject, string comment, string email, string type, bool notify, string datasetId, string datasetName, string parentType, string container, string captchaChallenge, string captchaResponse)
        {
            var validCaptcha = Recaptcha.Validate(captchaChallenge, captchaResponse, Request.UserHostAddress);

            if (!validCaptcha || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(subject) || string.IsNullOrEmpty(comment) || string.IsNullOrEmpty(datasetId))
            {
                return(EmptyHtml());
            }

            var result = new Comment
            {
                Subject         = subject,
                Body            = comment,
                Posted          = DateTime.Now,
                Email           = email,
                Type            = type,
                Status          = "New",
                Notify          = notify && !string.IsNullOrEmpty(email),
                ParentName      = datasetId,
                ParentType      = parentType,
                Author          = name,
                ParentContainer = container,
            };

            CommentRepository.AddComment(result);

            string linkToParent = Request.UrlReferrer.AbsoluteUri;

            var ni = new NotifyInfo
            {
                CommentEntry = result,
                Link         = linkToParent,
                DatasetName  = datasetName,
            };
            Action <NotifyInfo> notification = SendNotification;

            notification.BeginInvoke(ni, null, null);

            return(View("Comment", result));
        }
Exemple #20
0
        public JsonResult Index(string comment)
        {
            if (!String.IsNullOrEmpty(comment))
            {
                Comment           c   = new Comment();
                CommentRepository rep = new CommentRepository();

                c.CommentText = comment;
                String strUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                if (!String.IsNullOrEmpty(strUser))
                {
                    int slashPos = strUser.IndexOf("\\");
                    if (slashPos != -1)
                    {
                        strUser = strUser.Substring(slashPos + 1);
                    }
                    c.UserName = strUser;

                    rep.AddComment(c);
                }
                else
                {
                    c.UserName = "******";
                }

                IEnumerable <Comment> comment_list = rep.GetComments();
                foreach (var co in comment_list)
                {
                    System.Diagnostics.Debug.WriteLine(co.ID);
                }
                return(Json(comment_list, JsonRequestBehavior.AllowGet));

                //return Json(c, JsonRequestBehavior.AllowGet);
            }
            else
            {
                ModelState.AddModelError("CommentText", "Silly goose, you gonna comment with nothing?");
                return(Json("Could not add comment", JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Book(string commentText, int id)
        {
            string userName = User.Identity.Name;

            if (userName == null)
            {
                return(Book(id));
            }
            CommentRepository cr      = new CommentRepository();
            Comment           comment = new Comment
            {
                Text              = commentText,
                UserName          = userName,
                Book_Id           = id,
                Date              = DateTime.Now,
                IsDownvotedByUser = false,
                IsUpvotedByUser   = false
            };

            cr.AddComment(comment);

            return(RedirectToAction("Book", new { id = id }));
        }
        protected override bool AddItem()
        {
            string photoId = (string)Bucket.Instance.For.Item(CommentColumns.PhotoId).Value;
            string text    = (string)Bucket.Instance.For.Item(CommentColumns.Text).Value;

            if (string.IsNullOrEmpty(photoId))
            {
                throw new Exception("Must have valid photoId");
            }

            if (string.IsNullOrEmpty(text))
            {
                throw new Exception("Must have some text for the comment");
            }

            using (ICommentRepository commentRepositoryRepo = new CommentRepository(elementProxy))
            {
                string commentId = commentRepositoryRepo.AddComment(photoId, text);
                // set the id.
                Bucket.Instance.For.Item(CommentColumns.Id).Value = commentId;

                return(string.IsNullOrEmpty(commentId) == false);
            }
        }
Exemple #23
0
 public void AddComment(CommentModel comment) => _commentRepository.AddComment(comment);
        // POST api/comment
        public void Post(int id, [FromBody] PostCommentHelper message)
        {
            var repo = new CommentRepository();

            repo.AddComment(message.userId, id, message.value);
        }
Exemple #25
0
 public IActionResult Post(Comment comment)
 {
     comment.CreateDateTime = DateTime.Now;
     _commentRepository.AddComment(comment);
     return(CreatedAtAction("Get", new { id = comment.Id }, comment));
 }
Exemple #26
0
 public void PostComment(Comment comment)
 {
     repo.AddComment(comment);
 }