Пример #1
0
        public ActionResult AddComment(MovieCommentInputModel comment)
        {
            if (!this.User.Identity.IsAuthenticated)
            {
                this.Response.StatusCode = 401;
                return this.Content("Access is denied");
            }

            if (comment == null || !this.ModelState.IsValid)
            {
                this.Response.StatusCode = 400;
                return this.Content("Bad request");
            }

            var newComment = this.comments.Add(comment.Content, comment.MovieId, this.User.Identity.GetUserId());
            if (newComment == null)
            {
                this.Response.StatusCode = 400;
                return this.Content("Bad request.");
            }

            var viewModel = this.Mapper.Map<MovieCommentViewModel>(newComment);

            return this.PartialView("_MovieComment", viewModel);
        }
Пример #2
0
        public ActionResult AddComment(MovieCommentInputModel comment)
        {
            if (!this.User.Identity.IsAuthenticated)
            {
                this.Response.StatusCode = 401;
                return(this.Content("Access is denied"));
            }

            if (comment == null || !this.ModelState.IsValid)
            {
                this.Response.StatusCode = 400;
                return(this.Content("Bad request"));
            }

            var newComment = this.comments.Add(comment.Content, comment.MovieId, this.User.Identity.GetUserId());

            if (newComment == null)
            {
                this.Response.StatusCode = 400;
                return(this.Content("Bad request."));
            }

            var viewModel = this.Mapper.Map <MovieCommentViewModel>(newComment);

            return(this.PartialView("_MovieComment", viewModel));
        }
Пример #3
0
        public ActionResult AddComment(int id)
        {
            var viewModel = new MovieCommentInputModel()
            {
                Content = string.Empty,
                MovieId = id

            };
            return this.PartialView("_AddComment", viewModel);
        }
Пример #4
0
        public ActionResult AddComment(int id)
        {
            var viewModel = new MovieCommentInputModel()
            {
                Content = string.Empty,
                MovieId = id
            };

            return(this.PartialView("_AddComment", viewModel));
        }