예제 #1
0
        public void Update(GameUpdateBindingModel gameVM)
        {
            Game game = this.gameRepository.GetById(gameVM.Id);

            game.Title       = gameVM.Title;
            game.Description = gameVM.Description;
            game.Size        = gameVM.Size;
            game.ReleaseDate = DateTime.ParseExact(gameVM.Date, "yyyy-MM-dd", CultureInfo.InvariantCulture);
            game.VideoUrl    = gameVM.VideoUrl;
            game.Price       = gameVM.Price;

            this.gameRepository.Update(game);
            this.unitOfWork.Save();
        }
예제 #2
0
        public void Edit(HttpSession session, HttpResponse response, GameUpdateBindingModel game)
        {
            if (!this.securityService.IsAuthenticated(session))
            {
                this.Redirect(response, "/user/login");
                return;
            }

            if (!this.securityService.IsAdmin(session))
            {
                this.Redirect(response, "/home/index");
                return;
            }

            if (!game.IsValid())
            {
                this.Redirect(response, $"/games/edit?id={game.Id}");
                return;
            }

            this.gameService.Update(game);
            this.Redirect(response, "/games/all");
        }