public IActionResult Edit(int id, GameAdminModel model)
        {
            if (!this.IsAdmin)
            {
                return(this.Redirect("/"));
            }

            if (!this.IsValidModel(model))
            {
                this.ShowError(GameError);
                return(this.View());
            }

            this.games.Update(
                id,
                model.Title,
                model.Description,
                model.ThumbnailUrl,
                model.Price,
                model.Size,
                model.VideoId,
                model.ReleaseDate);

            return(this.Redirect("/admin/all"));
        }
        public IActionResult Edit(int id, GameAdminModel model)
        {
            // Accessible to Admins only
            if (!this.IsAdmin)
            {
                return(this.Redirect(HomePage));
            }

            // Validate model
            if (!this.IsValidModel(model))
            {
                this.ShowError(GameError);
                return(this.View());
            }

            // Update game in db
            var result = this.gamesService.Update(
                id, model.Title, model.Description, model.ThumbnailUrl,
                model.Price, model.Size, model.VideoId, model.ReleaseDate);

            if (!result)
            {
                this.ShowError(string.Format(GameNotFound, id));
                return(this.Games());
            }

            return(this.Redirect(AdminGamesPath));
        }
        public IActionResult Add(GameAdminModel model)
        {
            // Accessible to Admins only
            if (!this.IsAdmin)
            {
                return(this.Redirect(HomePage));
            }

            // Validate model
            if (!this.IsValidModel(model))
            {
                this.ShowError(GameError);
                return(this.View());
            }

            // Create Game in db
            this.gamesService.Create(
                model.Title, model.Description, model.ThumbnailUrl,
                model.Price, model.Size, model.VideoId, model.ReleaseDate);

            return(this.Redirect(AdminGamesPath));
        }
Esempio n. 4
0
        public IActionResult Add(GameAdminModel model)
        {
            if (!this.IsAdmin)
            {
                return(this.RedirectToHome());
            }

            if (!this.IsValidModel(model))
            {
                this.ShowError(GameError);
                return(this.View());
            }

            this.games.Create(
                model.Title,
                model.Description,
                model.ThumbnailUrl,
                model.Price,
                model.Size,
                model.VideoId,
                model.ReleaseDate);

            return(this.RedirectToAllGames());
        }