Пример #1
0
        public ActionResult Comment(CommentAdd comment)
        {
            ViewBag.Projects = project.ListofProjects();
            ViewBag.Tasks    = _taskManager.Listoftask();

            commentManager.AddComment(comment);
            return(View());
        }
Пример #2
0
        public IActionResult PostComment([FromBody] CommentAdd commentAdd)
        {
//            if (!ModelState.IsValid)
//            {
//                return BadRequest(ModelState);
//            }

            var comment = commentService.AddComment(commentAdd);

            return(Ok(comment));
        }
Пример #3
0
        public int AddComment(CommentAdd comment)
        {
            Connection.Open();
            string query = "Insert into Comment Values ('" + comment.ProjectId + "','" + comment.TaskId + "','" + comment.Comments + "')";

            Command.CommandText = query;
            int rowaffected = Command.ExecuteNonQuery();

            Connection.Close();
            return(rowaffected);
        }
Пример #4
0
        public IHttpActionResult PostComment(CommentAdd model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateCommentService();

            if (!service.AddComment(model))
            {
                return(InternalServerError());
            }
            return(Ok("Comment Added"));
        }
Пример #5
0
        public bool AddComment(CommentAdd model)
        {
            var entity = new Comment()
            {
                AuthorID = _userID,
                Text = model.Text,
                Id = model.PostID

            };
            using (var ctx = new ApplicationDbContext())
            {
                ctx.Comments.Add(entity);
                return ctx.SaveChanges() == 1;
            }
        }
Пример #6
0
        public virtual ActionResult Comment(CommentAdd commentAdd)
        {
            if (ModelState.IsValid)
            {
                var comment = new Comment();
                Mapper.Map(commentAdd, comment);
                comment.CreatedAt = DateTime.UtcNow;
                RavenSession.Advanced.DocumentStore.DatabaseCommands.Patch(
                    commentAdd.PostDocumentId,
                    new[] {
                    new PatchRequest {
                        Type  = PatchCommandType.Add,
                        Name  = Reflect.GetName <Post>(p => p.Comments),
                        Value = RavenJObject.FromObject(comment)
                    }
                });
                return(RedirectToAction(commentAdd.ReturnUrl));
            }

            return(View());
        }
Пример #7
0
        public CommentModel AddComment(CommentAdd commentAdd)
        {
            var comment = mapper.Map <Comment>(commentAdd);

            var task = unitOfWork.TaskRepository.GetByID(commentAdd.TaskId);

            comment.Task = task;
            if (commentAdd.MilestoneID != null)
            {
                var milestone = unitOfWork.MilestoneRepository.GetByID(commentAdd.MilestoneID);
                comment.Milestone = milestone;
            }
            var user = unitOfWork.UserRepository.GetByID(commentAdd.UserId);

            comment.User = user;


            unitOfWork.CommentRepository.Insert(comment);
            unitOfWork.Save();

            return(mapper.Map <CommentModel>(comment));
        }
 public int AddComment(CommentAdd comment)
 {
     return(commentGateway.AddComment(comment));
 }