public static void CreateCharacter(string name, string password) { using (var DbContext = new TheTieSilincerContext()) { try { PlayerDbEntity newPlayer = new PlayerDbEntity(name, password); DbContext.Players.Add(newPlayer); GameService.currentPlayer = newPlayer; DbContext.SaveChanges(); } catch (CustomRegisterException ex) { RegisterMenu.RegisterNewPlayer(ex.Message); } } }
public static void CheckLogIn(string name, string password) { using (var DbContext = new TheTieSilincerContext()) { var players = DbContext .Players .Where(x => x.Name == name && x.Password == password); try { if (players.Count() == 0) { throw new InvalidNameAndPasswordMatchException(); } PlayerDbEntity Player = players.First(); GameService.currentPlayer = Player; } catch (CustomLogInException ex) { RegisterMenu.LogIn(ex.Message); } } }