public IActionResult Post([FromBody] CommentModel model) { var comment = ModelFactory.cMap(model); DataService.AddComment(comment); return(Ok(ModelFactory.cMap(comment, Url))); }
public PartialViewResult AddComment(Guid itemId, ItemTypeEnum itemType, Guid?parentCommentId, string commentText) { if (!string.IsNullOrEmpty(commentText) && User.UserId != null) { BaseItemModel data = null; Guid newItemId = DataService.AddComment(itemId, (Guid)User.UserId, parentCommentId, commentText, itemType); _mailService.NewComment(newItemId); switch (itemType) { case ItemTypeEnum.Author: data = DataService.GetAuthor(itemId, User.UserId); break; case ItemTypeEnum.Book: data = DataService.GetBook(itemId, User.UserId); break; case ItemTypeEnum.Serie: data = DataService.GetSerie(itemId, User.UserId); break; case ItemTypeEnum.Review: data = DataService.GetReview(itemId, User.UserId); break; } return(PartialView("~/Views/Partial/Comments.cshtml", data)); } return(null); }
public async Task <ActionResult> Comment(Details model) { if (ModelState.IsValid) { using (var db = new DataService()) { // User id Int32 userId = UserService.Get()?.Id ?? 0; // Create the comment await db.AddComment(model.Comment.Text, userId, model.Post.Id); } } return(RedirectToAction("Details", new { id = model.Post.Id })); }
public async Task <ActionResult> Comment(Details model) { if (ModelState.IsValid) { // User id Int32 userId = _userService.Get()?.Id ?? 0; // Create the comment if (_dataService.AddComment(model.Comment.Text, userId, model.Post.Id)) { await _mailService.NotifyUsersForComment(model.Post.Id, userId); } } return(RedirectToAction("Details", new { id = model.Post.Id })); }