public PlayerPerformance CurrentPlayer(long accountId) { using (MatchesHistoryDbContext db = new MatchesHistoryDbContext()) { return(db .PlayersPerformance .FirstOrDefault(pp => pp.AccountId == accountId)); } }
public void AddRangeJSONToDatabase(HashSet <Result> results) { using (MatchesHistoryDbContext db = new MatchesHistoryDbContext()) { db .Results .AddRange(results); db.SaveChanges(); } }
public void AddJSONToDatabase(Result result) { using (MatchesHistoryDbContext db = new MatchesHistoryDbContext()) { db .Results .Add(result); db.SaveChanges(); } }
public List <long> GetAllMatchesIds() { using (MatchesHistoryDbContext db = new MatchesHistoryDbContext()) { List <long> allMatchesIds = new List <long>(); foreach (var result in db.Results) { allMatchesIds.Add(result.MatchId); } return(allMatchesIds); } }
public void UpdatePlayerPerformance(PlayerPerformance playerPerformance) { using (MatchesHistoryDbContext db = new MatchesHistoryDbContext()) { if (db.PlayersPerformance.FirstOrDefault(p => p.AccountId == playerPerformance.AccountId) == null) { db.PlayersPerformance.Add(playerPerformance); } else { var entity = playerPerformance; } db.SaveChanges(); } }
public long GetLastAddedMatch() { using (MatchesHistoryDbContext db = new MatchesHistoryDbContext()) { var results = db.Results; var matchesIds = new List <long>(); foreach (var result in results) { matchesIds.Add(result.MatchId); } matchesIds.Sort(); return(matchesIds.LastOrDefault()); } }
public List <Result> LastMonthResults() { using (MatchesHistoryDbContext db = new MatchesHistoryDbContext()) { List <Result> results = new List <Result>(); long startTime = DateTime.Now.Millisecond; results = db .Results .Where(r => r.StartTime > startTime) .Include(r => r.Players) .ToList(); return(results); } }
public static void Main() { string json = string.Empty; while (true) { var line = Console.ReadLine(); if (line == "end") { break; } json += line; } List <Hero> heroes = JsonConvert.DeserializeObject <RootObject>(json).Heroes; using (var db = new MatchesHistoryDbContext()) { foreach (Hero currentHero in heroes) { string imageFull = string.Format("C:\\Users\\User\\Desktop\\DotaProject\\HeroesFull\\{0}_full.png", currentHero.Name); var currentImageFull = Image.FromFile(imageFull); currentHero.ImageFull = ImageToByteArray(currentImageFull); string imageOver = string.Format("C:\\Users\\User\\Desktop\\DotaProject\\HeroesOver\\{0}_hphover.png", currentHero.Name); var currentImageOver = Image.FromFile(imageOver); currentHero.ImageOver = ImageToByteArray(currentImageOver); db.Heroes.Add(currentHero); } db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT SomeDotes.dbo.Heroes ON;"); db.SaveChanges(); db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT SomeDotes.dbo.Heroes OFF;"); } }