/// <summary> /// Create new OBLAST with selected level of game (OBTIZNOST) /// </summary> /// <param name="obt"> /// ID of level of game: /// 1 - beginner /// 2 - advanced /// 3 - expert /// </param> /// <returns>ID of OBLAST of created game, which will be used for playing</returns> public static int AddGame(int obt) { using (var db = new postgresEntities()) { var oblast = new OBLAST { obtiznost = obt }; db.OBLAST.Add(oblast); try { db.SaveChanges(); db.Entry(oblast).GetDatabaseValues(); return(oblast.oblast_id); } catch (Exception e) { Console.WriteLine(e.InnerException.InnerException.Message); return(-1); } } }
/// <summary> /// Add new Difficulty level for new game. Create level with custom height, width and num of mines /// </summary> /// <param name="selectedHeight">Custom height</param> /// <param name="selectedWidth">Custom width</param> /// <param name="selectedMine">Custom number of mines</param> /// <returns>ID of newly created difficulty OBTIZNOST</returns> public static int AddObtiznost(int selectedHeight, int selectedWidth, int selectedMine) { using (var db = new postgresEntities()) { int id = db.OBTIZNOST.Count() + 1; var obtiznost = new OBTIZNOST { nazev = "custom" + id, omezeni = 1, vyska = selectedHeight, sirka = selectedWidth, pocet_min = selectedMine, obtiznost_id = id }; db.OBTIZNOST.Add(obtiznost); try { db.SaveChanges(); db.Entry(obtiznost).GetDatabaseValues(); return(obtiznost.obtiznost_id); } catch (Exception e) { Console.WriteLine(e.InnerException.InnerException.Message); return(-1); } } }