internal async static Task <string> GetGamerNameByGuidAsync(Guid gamerGuid) // returns task to get gamer name by Guid { using (Game2048Entities context = new Game2048Entities()) { gmrGamer gamer = await context.gmrGamers.SingleOrDefaultAsync(x => x.gmrGamerId == gamerGuid); return(gamer.gmrGamerName); } }
public static void SendGamerToDatabase(Guid gamerGuid, string gamerName) // create new gamer in database { using (Game2048Entities context = new Game2048Entities()) { // Create a new Gamer object. gmrGamer gmr = new gmrGamer { gmrGamerId = gamerGuid, gmrGamerName = gamerName }; // Add the new object to the Gamer collection. context.gmrGamers.Add(gmr); try { context.SaveChanges(); } catch (Exception e) { Debug.Print(e.InnerException.ToString()); } } }