Ejemplo n.º 1
0
        protected void CommentButton_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Content.Text.Trim()))
            {
                Response.Write("<script>alert('내용을 입력해주세요.');</script>");
            }
            else if (Session["UserID"] == null)
            {
                // 로그인 페이지로 Redirect
                Response.Redirect("/Login.aspx?classification=2&state=" + Request.QueryString["state"] + "&id=" + Request.QueryString["id"]);
            }
            else
            {
                CommentButton.Enabled = false;

                CommentManager.AddComment(new Models.Comment {
                    PostID         = int.Parse(Request.QueryString["id"]),
                    Content        = Content.Text,
                    WriterID       = (string)Session["UserID"],
                    CommentAt      = DateTime.Now.AddHours(9),
                    Classification = 2
                });

                CommentButton.Enabled = true;

                Response.Redirect(Request.RawUrl);
            }
        }
        public ActionResult MyAddComment(string comment_title, string comment_content, int project_id)
        {
            ProjectManager pm     = new ProjectManager();
            Notification   not    = new Notification();
            bool           result = false;
            int            userid = (Session["user"] as User).Id;
            CommentManager cm     = new CommentManager();

            result = cm.AddComment(project_id, userid, comment_content, comment_title);
            if (!result)
            {
                not.Type      = 0;
                not.FromWho   = userid;
                not.Comment   = comment_content;
                not.Date      = DateTime.Now;
                not.ToWho     = -1;
                not.projectid = project_id;
                nm.Insert(not);
                ViewBag.CommentResult = "Yorum ekleme işlemi başarılı";
                ViewBag.Color         = "success";
            }
            else
            {
                ViewBag.CommentResult = "Yorum Eklerken Bir Hata Meydana Geldi";
                ViewBag.Color         = "danger";
            }
            TempData["projectid"] = project_id;
            Project project = pm.Find(x => x.Id == project_id);

            TempData["projectOwner"] = project.user.UserName;
            TempData["projectImage"] = "/ProjectImages/" + project_id.ToString() + ".png";
            return(RedirectToAction("Show", "Project", pm.Find(x => x.Id == project_id)));
        }
        public async Task <IHttpActionResult> Comment(string token, string postId, [FromBody] Comment comment)
        {
            if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(postId) || comment == null)
            {
                return(BadRequest("Token or post id or comment missing."));
            }

            string userId = await Utils.VerifyAndDecrypt(token);

            if (string.IsNullOrEmpty(userId))
            {
                return(BadRequest("Token not valid."));
            }

            try
            {
                _commentMng.AddComment(userId, postId, comment);
                return(Ok());
            }
            catch (IncorrectDetailsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.InternalServerError, e.Message));
            }
        }
Ejemplo n.º 4
0
        public string DodajKomentarz(string Comment, int Product)
        {
            if (User.Identity.Name == "")
            {
                return("SIGNIN");
            }
            if (!ProductManager.CheckProductExistsID(Product))
            {
                return("ERROR");
            }

            if (string.IsNullOrWhiteSpace(Comment) || Comment.Length < 3 || Comment.Length > 500)
            {
                return("ERROR");
            }

            bool isAdded = CommentManager.AddComment(User.Identity.Name, Product, Comment);

            if (isAdded)
            {
                return("OK");
            }
            else
            {
                return("OK");
            }
        }
Ejemplo n.º 5
0
    protected void btnCommit_ServerClick(object sender, EventArgs e)
    {
        int     id      = Convert.ToInt32(Request.QueryString["aid"]);
        Article article = ArticleManager.GetArticleById(id);

        string commentContent = Server.HtmlEncode(this.txtComment.Text.ToString());

        if (commentContent.Length > 250)
        {
            commentContent = commentContent.Substring(0, 250);
        }
        Comment comment = new  Comment();

        comment.Article    = article;
        comment.AuthorName = this.txtCommentName.Text.ToString();
        comment.Contents   = commentContent;
        comment.PubDate    = DateTime.Now;
        if (CommentManager.AddComment(comment) != null)
        {
            Response.Redirect("article.aspx?aid=" + id);
            Response.Write("alert(\"恭喜您,评论发表成功!\")");
        }
        else
        {
            this.lblErrorComment.Text = "很抱歉,你的评论发表失败,请重新尝试!";
        }
    }
Ejemplo n.º 6
0
        public ActionResult Comment(CommentAdd comment)
        {
            ViewBag.Projects = project.ListofProjects();
            ViewBag.Tasks    = _taskManager.Listoftask();

            commentManager.AddComment(comment);
            return(View());
        }
        public bool CommentWasAdded()
        {
            var ticket       = new Ticket();
            var manager      = new CommentManager(ticket);
            int commentCount = ticket.Comments.Count;

            manager.AddComment(Comment, CommentedOn, Username);
            return(ticket.Comments.Count == commentCount + 1);
        }
Ejemplo n.º 8
0
        public JsonResult MakeComment(string text, int noteid)
        {
            CommentManager commentManager = new CommentManager();

            BlogUser user = Session["login"] as BlogUser;

            commentManager.AddComment(text, noteid, user);

            return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 9
0
 protected void btnPut_Click(object sender, EventArgs e)
 {
     //int Id = Convert.ToInt32(Request.QueryString["ThemeId"]);
     Models.Questions qs1 = new Models.Questions();
     qs1.ThemeId       = Convert.ToInt32(Request.QueryString["ThemeId"]);
     qs1.Author        = txtCommentName.Text;
     qs1.R_Content     = txtComment.Text;
     qs1.R_PublishTime = DateTime.Now;
     CommentManager.AddComment(qs1);
     ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('添加成功')</script>");//向页面注册脚本
 }
Ejemplo n.º 10
0
        public ActionResult AddComment(Comment comment)
        {
            comment.Id         = Guid.NewGuid().ToString();
            comment.CreateTime = DateTime.UtcNow;

            try
            {
                commentManager.AddComment(comment);
                return(Redirect("~/Archives/" + HttpContext.Request.Form["ArticleNo"]));
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 11
0
        public ActionResult AddComment(Comment comment)
        {
            comment.Id         = Guid.NewGuid().ToString();
            comment.CreateTime = DateTime.UtcNow;
            comment.PostId     = "1";

            try
            {
                commentManager.AddComment(comment);
                return(Redirect("~/Home/About"));
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 12
0
        public ActionResult Clients_addComment(string itemID, string text)
        {
            var mng = new CommentManager();
            var item = mng.AddComment("clients", itemID, text);

            var res = true;
            return Json(new
            {
                result = res,
                item = new
                {
                    item.id,
                    created = item.created.GetValueOrDefault().ToString("dd.MM.yyyy HH:mm"),
                    item.username,
                    item.text
                }
            }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 13
0
        public ActionResult Partners_addComment(string itemID, string text, HttpPostedFileBase audioBlob)
        {
            var mng = new CommentManager();

            string audio = string.Empty;

            if (audioBlob != null)
            {
                var folderPath = System.Web.HttpContext.Current.Server.MapPath(@"/uploads/comm_voice");
                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }

                audio = Path.Combine(folderPath, Guid.NewGuid() + ".mp3");

                //http://stackoverflow.com/questions/20088743/mvc4-app-unable-to-load-dll-libmp3lame-32-dll
                CheckAddBinPath();

                using (var writer = new NAudio.Lame.LameMP3FileWriter(audio, new NAudio.Wave.WaveFormat(44100, 16, 2), NAudio.Lame.LAMEPreset.STANDARD))
                {
                    audioBlob.InputStream.CopyTo(writer);
                }
            }

            var item = mng.AddComment("customer", itemID, text, audio);

            var res = true;

            return(Json(new
            {
                result = res,
                item = new
                {
                    item.id,
                    created = item.created.GetValueOrDefault().ToString("dd.MM.yyyy HH:mm"),
                    item.username,
                    item.text,
                    audio = PathMap(item.audio)
                }
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 14
0
        public JsonResult PostComment(string content, int postID, int postOwnerID)
        {
            int userID = 0;

            content = content.Trim();
            userID  = (int)Session["CurrentUserID"];
            bool returnValue = false;

            if (!string.IsNullOrEmpty(content) && userID != 0 && postID != 0 && postOwnerID != 0)
            {
                returnValue = commentManager.AddComment(new COMMENT()
                {
                    CONTENT   = content,
                    POSTER_ID = userID,
                    POST_ID   = postID
                }, postOwnerID);
            }

            return(Json(new { Status = returnValue }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 15
0
        public ActionResult AddComment(Comment comment)
        {
            if (CheckAuthProjectManagerAndOther() == 0)
            {
                ViewBag.ErrorMessage = "Log in first";
                return(RedirectToAction("LogIn", "UserAuthentication"));
            }
            else if (CheckAuthProjectManagerAndOther() == 1)
            {
                User user = userManager.GetUserById(Convert.ToInt32(Session["UserId"]));

                ViewBag.UserName = user.Name;

                if (ModelState.IsValid)
                {
                    comment.ActionById = Convert.ToInt32(Session["UserId"]);
                    comment.ActionDone = ActionUtility.ActionInsert;
                    comment.ActionTime = DateTime.Now.ToString();

                    ViewBag.Response = commentManager.AddComment(comment);

                    ViewBag.Projects = projectManager.GetAllProjectsForDropDown();
                    ModelState.Clear();
                    return(View());
                }
                else
                {
                    ViewBag.Response = "Fill up all fields correctly";

                    ViewBag.Projects = projectManager.GetAllProjectsForDropDown();
                    return(View(comment));
                }
            }
            else
            {
                return(HttpNotFound());
            }
        }
Ejemplo n.º 16
0
        /// <summary> Write up-to-date notes from the mongo database to the Paratext project folder </summary>
        public void PutNotes(UserSecret userSecret, string projectId, string notesText)
        {
            // TODO: should accept some data structure instead of XML
            string        username = GetParatextUsername(userSecret);
            List <string> users = new List <string>();
            int           nbrAddedComments = 0, nbrDeletedComments = 0, nbrUpdatedComments = 0;
            ScrText       scrText = ScrTextCollection.FindById(username, projectId);

            if (scrText == null)
            {
                throw new DataNotFoundException("Can't get access to cloned project.");
            }
            CommentManager manager = CommentManager.Get(scrText);
            var            ptUser  = new SFParatextUser(username);
            var            notes   = NotesFormatter.ParseNotes(notesText, ptUser);

            // Algorithm sourced from Paratext DataAccessServer
            foreach (var thread in notes)
            {
                CommentThread existingThread = manager.FindThread(thread[0].Thread);
                foreach (var comment in thread)
                {
                    var existingComment = existingThread?.Comments.FirstOrDefault(c => c.Id == comment.Id);
                    if (existingComment == null)
                    {
                        manager.AddComment(comment);
                        nbrAddedComments++;
                    }
                    else if (comment.Deleted)
                    {
                        existingComment.Deleted = true;
                        nbrDeletedComments++;
                    }
                    else
                    {
                        existingComment.ExternalUser   = comment.ExternalUser;
                        existingComment.Contents       = comment.Contents;
                        existingComment.VersionNumber += 1;
                        nbrUpdatedComments++;
                    }

                    if (!users.Contains(comment.User))
                    {
                        users.Add(comment.User);
                    }
                }
            }

            try
            {
                foreach (string user in users)
                {
                    manager.SaveUser(user, false);
                }
                _paratextDataHelper.CommitVersionedText(scrText, $"{nbrAddedComments} notes added and "
                                                        + $"{nbrDeletedComments + nbrUpdatedComments} notes updated or deleted in synchronize");
                _logger.LogInformation("{0} added {1} notes, updated {2} notes and deleted {3} notes", userSecret.Id,
                                       nbrAddedComments, nbrUpdatedComments, nbrDeletedComments);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Exception while updating notes: {0}", e.Message);
            }
        }
Ejemplo n.º 17
0
 public Result <int> AddComment([FromRoute] int id, [FromBody] CommentViewModel comment)
 {
     return(_commentManager.AddComment(_requestAttributes.Id, id, comment));
 }
Ejemplo n.º 18
0
        public CommentModel AddComment(CommentModel commentModel)
        {
            Comment comment = CommentManager.AddComment(commentModel.Name, commentModel.Text, commentModel.ProjectId);

            return(Mapper.Map(comment));
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            TaskManager     taskManager     = TaskManager.GetTaskManager();
            UserManager     userManager     = UserManager.GetUserManager();
            CommentManager  commentManager  = CommentManager.GetCommentManager();
            ReactionManager reactionManager = ReactionManager.GetReactionManager();

            userManager.AddUser("dennis", "dennis");
            userManager.AddUser("saravana", "saravana");

            User newUser;

            do
            {
                Console.WriteLine("Enter your User Name");
                string username = Console.ReadLine();
                Console.WriteLine("Enter your Password");
                string password = Console.ReadLine();
                newUser = userManager.VerifyUser(username, password);
            } while (newUser == null);

            int option;

            do
            {
                Console.WriteLine("\nEnter Your Choice\n1.Create New Task \n2.List All Task \n3.Update Task\n4.Delete Task\n5.Comment on a Task\n6.Reply to a Comment\n7.View a Specific Task\n8.Like a Task\n9.Like a Comment\n0.Quit");
                option = Convert.ToInt32(Console.ReadLine());

                switch (option)
                {
                case 1:
                    Console.WriteLine("Enter Name of the task");
                    string taskName = Console.ReadLine();
                    Console.WriteLine("Assigned To (User Id)");
                    uint assignedTo = Convert.ToUInt32(Console.ReadLine());
                    Console.WriteLine("Priority of the Task(Low/Medium/High)");
                    PriorityEnum Priority = Enum.Parse <PriorityEnum>(Console.ReadLine());

                    Console.WriteLine("Due Date(1-31)");
                    int date = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Due Month(1-12)");
                    int month = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Due Date(YYYY)");
                    int      year    = Convert.ToInt32(Console.ReadLine());
                    DateTime dueDate = new DateTime(year, month, date);

                    taskManager.AddTask(taskName, Priority, assignedTo, newUser.Id, DateTime.Now, dueDate);

                    break;

                case 2:

                    List <ZTask> allTasks = taskManager.ListAllTasks();

                    Console.WriteLine("List of all Tasks");

                    foreach (var ztask in allTasks)
                    {
                        Console.WriteLine($"Task Id: { ztask.Id}");
                        Console.WriteLine($"Task Name:{ ztask.TaskName}");
                        Console.WriteLine($"Priority:{ ztask.Priority}");
                        Console.WriteLine($"Assigned To:{ ztask.AssignedTo}");
                        Console.WriteLine($"Assigned By:{ ztask.AssignedBy}");
                        Console.WriteLine($"Assigned Date:{ ztask.AssignedDate}");
                        Console.WriteLine($"Due Date:{ ztask.DueDate}\n");
                    }
                    break;

                case 3:

                    Console.WriteLine("Enter the task Id for updating");
                    long taskId = Convert.ToInt64(Console.ReadLine());
                    Console.WriteLine("1.Update Task\n2.Update Priority\n3.Update Assigned To\n4.Update Due date");
                    int updateNo = Convert.ToInt32(Console.ReadLine());
                    Console.WriteLine("Enter the new data");
                    string newData = Console.ReadLine();

                    ZTask updateTask = taskManager.GetZTask(taskId);
                    switch (updateNo)
                    {
                    case 1:
                        updateTask.TaskName = newData;
                        break;

                    case 2:
                        updateTask.Priority = Enum.Parse <PriorityEnum>(newData);
                        break;

                    case 3:
                        updateTask.AssignedTo = Convert.ToUInt32(newData);
                        break;

                    case 4:
                        updateTask.DueDate = Convert.ToDateTime(newData);
                        break;
                    }

                    taskManager.UpdateTask(updateTask);

                    break;

                case 4:
                    Console.WriteLine("Enter the task ID:");
                    long deleteTaskId = Convert.ToInt64(Console.ReadLine());
                    taskManager.DeleteTask(deleteTaskId);
                    break;

                case 5:
                    Console.WriteLine("Enter the task ID:");
                    long commentTaskId = Convert.ToInt64(Console.ReadLine());

                    Console.WriteLine("Enter the Comment String");
                    string commentString = Console.ReadLine();

                    commentManager.AddComment(commentTaskId, commentString);

                    break;

                case 6:
                    Console.WriteLine("Enter the task ID:");
                    long replyTaskId = Convert.ToInt64(Console.ReadLine());
                    Console.WriteLine("Enter the Comment ID:");
                    long replyCommentId = Convert.ToInt64(Console.ReadLine());
                    Console.WriteLine("Enter the Reply String");
                    string replyString = Console.ReadLine();

                    commentManager.AddReply(replyCommentId, replyTaskId, replyString);

                    break;

                case 7:
                    Console.WriteLine("Enter the Specific task Number");
                    long  specTaskId = Convert.ToInt64(Console.ReadLine());
                    ZTask task       = taskManager.GetZTask(specTaskId);

                    Console.WriteLine($"Task Id: { task.Id}");
                    Console.WriteLine($"Task Name:{ task.TaskName}");
                    Console.WriteLine($"Priority:{ task.Priority}");
                    Console.WriteLine($"Assigned To:{ task.AssignedTo}");
                    Console.WriteLine($"Assigned By:{ task.AssignedBy}");
                    Console.WriteLine($"Assigned Date:{ task.AssignedDate}");
                    Console.WriteLine($"Due Date:{ task.DueDate}");
                    Console.WriteLine($"No of Likes: {task.Reaction.Count}");

                    if (task.Comment != null)
                    {
                        foreach (var comment in task.Comment)
                        {
                            Console.WriteLine($"Comment Id: {comment.Id}");
                            Console.WriteLine($"Comment : { comment.CommentString}");
                            Console.WriteLine($"Comment Parent Id : {comment.ParentId}");
                            Console.WriteLine($"Commented Time {comment.commentedDateTime}");
                            Console.WriteLine($"No of likes {comment.Reaction.Count}\n");
                        }
                    }

                    break;

                case 8:
                    Console.WriteLine("Enter the task ID:");
                    long likeTaskId = Convert.ToInt64(Console.ReadLine());
                    reactionManager.AddReactionToTask(newUser.Id, likeTaskId);

                    break;

                case 9:
                    Console.WriteLine("Enter the task ID:");
                    long likeCommentTaskId = Convert.ToInt64(Console.ReadLine());
                    Console.WriteLine("Enter the Comment ID:");
                    long likeCommentId = Convert.ToInt64(Console.ReadLine());
                    reactionManager.AddReactionToComment(newUser.Id, likeCommentId, likeCommentTaskId);

                    break;
                }
            } while (option != 0);
        }