public async Task <ActionResult <Comment> > PostComment(Comment comment) { _IComment.Add(comment); await _IComment.SaveAsync(); return(CreatedAtAction("GetComment", new { id = comment.CommentId }, comment)); }
public ActionResult CreateComment(Comment comment) { var tempmember = HttpContext.Session.GetObjectFromJson <Member>("Member"); comment.SubjectID = Id; comment.MemberID = tempmember.ID; _comment.Add(comment); return(RedirectToAction("SubjectDetails", "Category", new { id = comment.SubjectID })); }
public static bool Add(CommentInfo commentInfo) { commentInfo.CommentId = MaxCommentId() + 1; if (dal.Add(commentInfo)) { ContentManage.UpdateCommentAuditedAndUnaudited(commentInfo.GeneralId); return(true); } return(false); }
public ActionResult Create([Bind(Include = "Id,Name,Email,PostId,CommentHeader,CommentText,CommentTime")] Comment comment) { if (ModelState.IsValid) { _commentRepository.Add(comment); return(RedirectToAction("Index")); } ViewBag.PostId = new SelectList(_postRepository.GetAll(), "Id", "Title", comment.PostId); return(View(comment)); }
public ViewResult Create(Comment comment) { if (ModelState.IsValid) { _icomment.Add(comment); ViewBag.ValidationMessage = null; } else { ViewBag.ValidationMessage = "Validation not Passed."; } return(View("Add")); }
public async Task <ActionResult> Post(CommentsModel comment) { IEnumerable <CommentsViewModel> newModel; IEnumerable <Comment> model; try { if (!ModelState.IsValid) { return(BadRequest(ModelState.ValidationState)); } var userId = _usercontext.GetCurrentUser(); var comments = new Comment { Body = comment.Body, DatePosted = DateTime.Now, PostId = Guid.Parse(comment.PostId) }; await _commemtContext.Add(comments); if (!await _commemtContext.SaveChanges()) { return(StatusCode(StatusCodes.Status100Continue, new { Error = "an error occured while processing " })); } model = await _commemtContext.GetAllPostComment(comment.PostId); if (model.Count() > 0) { newModel = _mapper.Map <IEnumerable <Comment>, IEnumerable <CommentsViewModel> >(model); await _hub.Clients.All.SendAsync("comment", newModel); } } catch (Exception e) { _logger.LogError(e.InnerException?.ToString() ?? e.Message); _mailService.SendMail(string.Empty, e.InnerException?.ToString() ?? e.Message, "error"); return(StatusCode(statusCode: StatusCodes.Status500InternalServerError, "Internal server error")); } return(Ok(new { Success = "comment Sucessfully posted" })); }
//[ValidateAntiForgeryToken] public JsonResult Create([Bind(Include = "Name,Email,PostId,CommentHeader,CommentText,CommentTime")] Comment comment) { comment.CommentTime = DateTime.Now; if (ModelState.IsValid) { //// Test capcha but not success //if (!this.IsCaptchaValid("hi")) //{ // Response.StatusCode = (int)HttpStatusCode.BadRequest; // return Json("Capcha is incorrect!", MediaTypeNames.Text.Plain); //} _commentRepository.Add(comment); return(Json(JsonRequestBehavior.AllowGet)); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json("Data is incorrect!", MediaTypeNames.Text.Plain)); //return Json(new { success = false, responseText = "Data is incorrect!" }, JsonRequestBehavior.AllowGet); }
public void Add(Comment Object) { _IComment.Add(Object); }
public void AddComment(Comment c) { commentRepository.Add(c); }