public IActionResult Create()
        {
            var games = this.gamesService.GetAll <GameDropDownViewModel>();

            var viewModel = new ReviewCreateInputModel
            {
                Games = games,
            };

            return(this.View(viewModel));
        }
Esempio n. 2
0
        public IActionResult Add(ReviewCreateInputModel reviewCreateInputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(Redirect("/"));
            }

            var    review = AutoMapper.Mapper.Map <ReviewServiceModel>(reviewCreateInputModel);
            string userId = this.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            this.reviewsService.Create(review, userId);

            return(this.Redirect($"/Products/Details/{reviewCreateInputModel.ProductId}"));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create(string id)
        {
            var recipeServiceModel = await this.recipeService.GetByIdAsync(id);

            var reviewCreateInputModel = new ReviewCreateInputModel
            {
                Recipe = new ReviewCreateRecipeInputModel
                {
                    Id    = id,
                    Title = recipeServiceModel.Title,
                },
            };

            return(this.View(reviewCreateInputModel));
        }
        public async Task <IActionResult> Create(ReviewCreateInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                var games = this.gamesService.GetAll <GameDropDownViewModel>();

                input.Games = games;

                return(this.View(input));
            }

            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            await this.reviewsService.CreateAsync(input.GameId, input.IsPositive, input.Content, userId);

            var routeParams = this.gamesService.GetTitleUrlAndSubTitleById(input.GameId);
            var gameUrl     = routeParams[0];
            var subTitle    = routeParams[1];

            this.TempData["InfoMessage"] = "Review created successfully!";
            return(this.RedirectToAction("ByName", "Games", new { name = gameUrl, subTitle = subTitle }));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(ReviewCreateInputModel reviewCreateInputModel)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(reviewCreateInputModel));
            }

            var reviewServiceModel = reviewCreateInputModel.To <ReviewServiceModel>();

            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            reviewServiceModel.ReviewerId = userId;

            if (!await this.reviewService.CreateAsync(reviewServiceModel))
            {
                this.TempData["Error"] = CreateErrorMessage;

                return(this.View(reviewCreateInputModel));
            }

            return(this.Redirect($"/Recipes/Details/{reviewServiceModel.RecipeId}"));
        }