public static CommentServiceModel mapCommentEntityToModel(Comment comment) { CommentServiceModel model = new CommentServiceModel(); model.comment = comment.Comment1; model.id = comment.Id; return model; }
public static Comment unmapCommentEntityToModel(CommentServiceModel comment) { Comment model = new Comment(); model.Comment1 = comment.comment; model.CreateDate = DateTime.Now; model.LastUpdatedDate = DateTime.Now; model.Id = comment.id; return model; }
public async Task <IActionResult> DeleteComment(CommentServiceModel commentModel) { if (!ModelState.IsValid) { //var errors = ModelState.Select(x => x.Value.Errors) // .Where(y => y.Count > 0) // .ToList(); return(RedirectToAction(nameof(MovieDetails), new { id = commentModel.MovieId })); } await this.commentService.DeleteComment(commentModel.Id); TempData.AddSuccessMessage($"Comment successfully deleted !"); return(RedirectToAction(nameof(MovieDetails), new { id = commentModel.MovieId })); }
public async Task <IActionResult> PostComment(int id, CommentServiceModel model) { var product = this.products.ById(id); if (product == null) { return(NotFound()); } if (!ModelState.IsValid) { return(View(model)); } model.Content = this.html.Sanitize(model.Content); var authorId = this.userManager.GetUserId(User); await this.comments.CreateAsync(model.Content, id, authorId); TempData.AddSuccuessMessage($"Your comment has been posted!"); return(RedirectToAction(nameof(ProductsController.Details), "Products", new { area = string.Empty, id = id.ToString() })); }
public int insertComment(CommentServiceModel comment) { CommentsRepository repo = new CommentsRepository(entities); Comment model = DefectUtil.unmapCommentEntityToModel(comment); return repo.InsertComment(model); }
public async Task <IActionResult> DeleteComment(Guid id) { CommentServiceModel commentModel = await this.commentService.FindComment(id); return(View(commentModel)); }