Exemple #1
0
        public async Task <string> CommentMaterial(MaterialCommentInputModel model)
        {
            //TODO: Validate model
            var userId = httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            MaterialComment comment = new MaterialComment()
            {
                Text       = model.Text,
                AuthorId   = userId,
                MaterialId = model.MaterialId
            };

            db.MaterialComments.Add(comment);
            await db.SaveChangesAsync();

            var result = $"You have successfully made a comment!";

            return(result);
        }
Exemple #2
0
        public async Task <IActionResult> CommentCurrentMaterial(MaterialCommentInputModel comment)
        {
            await service.CommentMaterial(comment);

            return(Redirect("/Material/MaterialDetails/" + comment.MaterialId.ToString()));
        }