public bool InsertGameCatalog(GameCatalog model) { string name = model.Name; string sql = "select Name from GameCatalog "; using (IDbConnection db = new SqlConnection(connectionString)) { IEnumerable <GameCatalog> models = db.Query <GameCatalog>(sql); if (models.Count(item => item.Name == name) > 0) { return(false); } sql = "insert into GameCatalog (Name, Price, DescribeGame, TypeGame)" + "values (@Name, @Price, @DescribeGame,@TypeGame)"; db.Execute(sql, new { model.Name, model.Price, model.DescribeGame, model.TypeGame }); } return(true); }
public GameBot(BotServices services, GameBotAccessors stateAccessors, IOptions <LUISOptions> luisOptionsAccessor, GameCatalog gameCatalog) { _services = services; _stateAccessors = stateAccessors; _luisOptions = luisOptionsAccessor.Value; _gameCatalog = gameCatalog; }
private void Awake() { _instance = this; string cleanPath = SwitcherSettings.Data.GamesFolder; cleanPath = cleanPath.Replace('\\', '/'); repopulateCatalog(cleanPath); }
public ActionResult Games(GameCatalog gameCatalog) { var id = User.Identity.GetUserId(); ViewBag.sum = Repository.DBLogic.returnSum(id); var bal = BusinessLogic.BusinessLogic.SelectWallet(id); foreach (var item in bal) { ViewBag.balanc = item.Balance; } var gc = BusinessLogic.BusinessLogic.SelectGameCatalog(); Repository.DBLogic.AddGameToBasket(id, gameCatalog.Id, Convert.ToDouble(gameCatalog.Price)); return(Redirect("Games")); }
public void OnGet(string game) { var gameCatalog = new GameCatalog("Games"); var gameInfo = gameCatalog.GetGameInfo(game); GameTitle = gameInfo.Title; GameInfoJson = JsonConvert.SerializeObject(new { gameName = game, playerActor = gameInfo.PlayerActor, assets = gameInfo.Assets .Select(asset => new { key = asset.Key, url = $"/dist/games/{game}{asset.Url}", frameWidth = asset.FrameWidth, frameHeight = asset.FrameHeight }) }); }
public bool DeleteGameCatalog(GameCatalog model) { string name = model.Name; string sql = "select ID from GameCatalog "; using (IDbConnection db = new SqlConnection(connectionString)) { IEnumerable <GameCatalog> models = db.Query <GameCatalog>(sql); if (models.Count(item => item.Name == name) > 0) { return(false); } sql = "DELETE FROM GameCatalog WHERE ID = @Id"; db.Execute(sql, new { model.Id }); } return(true); }
public static void UpdateGame(Game game, GameCatalog catalog, int index) { catalog.Games[index] = game; }
public static void UpdateCatalog(GameCatalog catalog, string path) { XmlRepository.Update(catalog.Games, path); }
public static void SortByTitle(GameCatalog catalog) { catalog.Games.Sort(delegate(Game g1, Game g2) { return g1.Title.CompareTo(g2.Title); }); }
public static void SaveCatalog(GameCatalog catalog, string path) { XmlRepository.Create(catalog.Games, path); }
public static void DeleteGame(Game game, GameCatalog catalog) { catalog.Games.Remove(game); }
public static void AddGame(Game game, GameCatalog catalog) { if (!catalog.Games.Contains(game)) catalog.Games.Add(game); }
public IndexModel(GameCatalog gameCatalog) { GameNames = gameCatalog.GetGameNames().OrderBy(n => n); }
static GameCatalog FirstMenu() { int cmdint = 0; string cmd = ""; while (true) { Console.Clear(); int i = 1; Console.WriteLine("Выберите каталог из списка или создайте новый"); string[] files = Directory.GetFiles("DB"); Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); foreach (string name in files) { Console.WriteLine(i + ") " + name); i++; } Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Введите Create чтобы создать новый каталог"); Console.WriteLine("Введите Delete чтобы удалить каталог"); Console.Write("-> "); cmd = Console.ReadLine(); if (cmd == "Create") { Console.WriteLine("Введите название файла"); Console.Write("-> "); string filename = Console.ReadLine(); FileStream fs = File.Create("DB\\" + filename + ".xdb"); fs.Close(); GameCatalog catalog = new GameCatalog(); string fullname = "DB\\" + filename + ".xdb"; GameCatalogComponents.SaveCatalog(catalog, fullname); catalog.Name = fullname; return catalog; } else if (cmd == "Delete") { Console.WriteLine("Введите номер удаляемого файла"); Console.Write("-> "); string index = Console.ReadLine(); File.Delete(files[int.Parse(index) - 1]); } else if (int.TryParse(cmd, out cmdint)) { GameCatalog catalog = GameCatalogComponents.LoadCatalog(files[cmdint - 1]); catalog.Name = files[cmdint - 1]; return catalog; } } }
static void GameMenu(GameCatalog catalog) { string cmd = ""; while (cmd != "Exit") { Console.Clear(); int i = 1; Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); foreach (Game game in catalog.Games) { Console.WriteLine(i + ") " + game.Title); i++; } Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Console.WriteLine("Введите Play чтобы запустить игру"); Console.WriteLine("Введите Add чтобы добавить игру"); Console.WriteLine("Введите Update чтобы обновить информацию об игре"); Console.WriteLine("Введите Delete чтобы удалить игру"); Console.WriteLine("Введите Exit чтобы выйти из программы"); Console.Write("-> "); cmd = Console.ReadLine(); switch (cmd) { case "Play": try { Console.WriteLine("Выберите игру, которую хотите запустить"); Console.Write("-> "); int index1 = int.Parse(Console.ReadLine()) - 1; GameComponents.PlayGame(catalog.Games[index1]); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); } break; case "Add": GameCatalogComponents.AddGame(CreateGame(), catalog); GameCatalogComponents.SaveCatalog(catalog, catalog.Name); GameCatalogComponents.SortByTitle(catalog); break; case "Update": try { Console.WriteLine("Выберите игру, которую хотите обновить"); Console.Write("-> "); int index2 = int.Parse(Console.ReadLine()) - 1; if (index2 > catalog.Count) throw new Exception("Игры под таким номером нет"); Game newgame = UpdateGame(catalog.Games[index2].ID); GameComponents.UpdateGame(newgame, catalog.Name); GameCatalogComponents.UpdateGame(newgame, catalog, index2); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); } break; case "Delete": try { Console.WriteLine("Выберите игру, которую хотите удалить"); Console.Write("-> "); int index3 = int.Parse(Console.ReadLine()) - 1; if (index3 > catalog.Count) throw new Exception("Игры под таким номером нет"); GameComponents.DeleteGame(catalog.Games[index3].ID, catalog.Name); GameCatalogComponents.DeleteGame(catalog.Games[index3], catalog); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); } break; } } }