コード例 #1
0
ファイル: DefectUtil.cs プロジェクト: adramalech/KolabApp
 public static CommentServiceModel mapCommentEntityToModel(Comment comment)
 {
     CommentServiceModel model = new CommentServiceModel();
     model.comment = comment.Comment1;
     model.id = comment.Id;
     return model;
 }
コード例 #2
0
ファイル: DefectUtil.cs プロジェクト: adramalech/KolabApp
 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;
 }
コード例 #3
0
        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 }));
        }
コード例 #4
0
        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() }));
        }
コード例 #5
0
ファイル: DefectsService.cs プロジェクト: adramalech/KolabApp
 public int insertComment(CommentServiceModel comment)
 {
     CommentsRepository repo = new CommentsRepository(entities);
     Comment model = DefectUtil.unmapCommentEntityToModel(comment);
     return repo.InsertComment(model);
 }
コード例 #6
0
        public async Task <IActionResult> DeleteComment(Guid id)
        {
            CommentServiceModel commentModel = await this.commentService.FindComment(id);

            return(View(commentModel));
        }