public ActionResult Comment(CommentAdd comment) { ViewBag.Projects = project.ListofProjects(); ViewBag.Tasks = _taskManager.Listoftask(); commentManager.AddComment(comment); return(View()); }
public IActionResult PostComment([FromBody] CommentAdd commentAdd) { // if (!ModelState.IsValid) // { // return BadRequest(ModelState); // } var comment = commentService.AddComment(commentAdd); return(Ok(comment)); }
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); }
public IHttpActionResult PostComment(CommentAdd model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCommentService(); if (!service.AddComment(model)) { return(InternalServerError()); } return(Ok("Comment Added")); }
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; } }
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()); }
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)); }