public JsonResult Games(String function, GameTypeViewModel game)
        {
            if (account.IsAdministrator())
            {
                GameType gameType = new GameType(service);

                switch (function)
                {
                case "add":
                    status = gameType.Create(game);
                    break;

                case "delete":
                    status = gameType.Delete(game);
                    break;
                }
                gameType.Retrieve();
                message = "Was able to " + function + " " + (status ? "successfully" : "unsuccessfully");
                data    = new
                {
                    games = gameType.Games.Select(x => new { x.GameTypeID, x.Title }).ToList()
                };
            }

            return(BundleJson());
        }
        public bool Create(GameTypeViewModel viewModel)
        {
            this.viewModel = viewModel;
            ApplyChanges();

            services.Type.AddGameType(Model);
            return(services.Save());
        }
示例#3
0
        public void GivenAGameTypeNamedNAME(string gameType)
        {
            var model = new GameTypeViewModel
            {
                Code        = gameType,
                DisplayName = gameType
            };

            GameTypesController.Create(model);
        }
示例#4
0
        public IActionResult Create(GameTypeViewModel viewModel)
        {
            _gamesService.CreateGameType(new GameType
            {
                Code        = viewModel.Code,
                DisplayName = viewModel.DisplayName
            });

            return(RedirectToAction("Index"));
        }
示例#5
0
        public GameTypeViewModel GetGameType(int id)
        {
            var gameType = this.DbContext
                           .GameTypes
                           .Include(x => x.Games)
                           .FirstOrDefault(x => x.Id == id);

            if (gameType == null)
            {
                return(null);
            }

            var gameTypeModel = new GameTypeViewModel()
            {
                GameTypeName = gameType.GameTypeName,
                Games        = this.Mapper.Map <ICollection <GameConciseViewModel> >(gameType.Games)
            };

            return(gameTypeModel);
        }
 public bool Delete(GameTypeViewModel viewModel)
 {
     services.Type.DeleteGameType(viewModel.GameID);
     return(services.Save());
 }