public SetupContract(Setup setup) { PlayerName = setup.PlayerName; Top = setup.Top; Jungle = setup.Jungle; Mid = setup.Mid; Supp = setup.Supp; Adc = setup.Adc; }
public int SendSetup(SetupContract setup) { var setupModel = new Setup() { PlayerName = setup.PlayerName, Top = setup.Top, Jungle = setup.Jungle, Mid = setup.Mid, Supp = setup.Supp, Adc = setup.Adc }; using (var context = new MyContext()) { var game = context.Games.FirstOrDefault(m => m.PlayerTwo == null); if(game != null) { game.PlayerTwo = setupModel; game.Winner = game.PlayerOne; game.TimeStamp = DateTime.Now; } else { game = new Game() { PlayerOne = setupModel, TimeStamp = DateTime.Now, }; context.Games.Add(game); } context.SaveChanges(); return game.Id; } }