예제 #1
0
        public void Insert(GameAdditionBindingModel gameBindingModel)
        {
            Game game = new Game
            {
                Title          = gameBindingModel.Title,
                Price          = gameBindingModel.Price,
                Size           = gameBindingModel.Size,
                VideoUrl       = gameBindingModel.VideoUrl,
                Description    = gameBindingModel.Description,
                ReleaseDate    = DateTime.ParseExact(gameBindingModel.Date, "yyyy-MM-dd", CultureInfo.InvariantCulture),
                ImageThumbnail = gameBindingModel.Thumbnail
            };

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

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

            if (!gameBindingModel.IsValid())
            {
                this.Redirect(response, "/games/add");
                return;
            }

            this.gameService.Insert(gameBindingModel);

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