Exemplo n.º 1
0
        public ActionResult AddReview(CommentToTeacher review)
        {
            var userId = User.Identity.GetUserId();

            review.DateAdd  = DateTime.Now;
            review.AuthorId = userId;
            _db.CommentsToTeacher.Add(review);
            _db.SaveChanges();
            var allReviews = _db.CommentsToTeacher.ToList();
            int id         = allReviews.Last().Id;

            return(RedirectToAction("Review", new { commentId = id }));
        }
Exemplo n.º 2
0
        public CommentToTeacherDto GetComment(CommentToTeacher comment)
        {
            CommentToTeacherDto commentDto = new CommentToTeacherDto();

            if (comment != null)
            {
                var user = _db.Users.Find(comment.AuthorId);
                commentDto.Id        = comment.Id;
                commentDto.DateAdd   = comment.DateAdd;
                commentDto.Text      = comment.Text;
                commentDto.FirstName = user.FirstName;
                commentDto.SurName   = user.SurName;
            }

            return(commentDto);
        }