public string Get(string name)
        {
            bool   x      = false;
            MatchQ posted = new MatchQ();

            posted.name  = name;
            posted.ready = ready;
            using (MatchDb db = new MatchDb())
            {
                using (BattleshipDb m = new BattleshipDb())
                {
                    while (x == false)
                    {
                        x = true;
                        Random rnd = new Random();
                        for (int i = 0; i < db.matches.ToList().Count(); i++)
                        {
                            if ((m.Battleships.Where(t => t.gameId == rnd.Next(10000, 1000000)).Count() > 0) && db.matches.Where(t => t.matchId == rnd.Next(10000, 1000000)).Count() > 0) // Check if element exists
                            {
                                x = false;
                            }
                        }
                    }
                    //db.matches.Add();
                    db.SaveChanges();
                    return("working f****r");
                }
            }
        }
 public void Delete(int id)
 {
     using (MatchDb db = new MatchDb())
     {
         if (db.matches.Where(t => t.playerId == id).Count() > 0) // Check if element exists
         {
             db.matches.Remove(db.matches.First(t => t.playerId == id));
         }
         db.SaveChanges();
     }
 }
Example #3
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            MinimumSize = Size;

            Logger.Initialize();
            HeroDb.Initialize();
            MatchDb.Initialize();

            ResetFilters();
        }
 public MatchQ Put(int id, string name)
 {
     using (MatchDb db = new MatchDb()){
         bool x = false;
         db.matches.First(t => t.gameId == id).name  = name;
         db.matches.First(t => t.gameId == id).ready = true;
         while (x == false)
         {
             x = true;
             Random rnd = new Random();
             for (int i = 0; i < db.matches.ToList().Count(); i++)
             {
                 if (db.matches.Where(t => t.playerId == rnd.Next(10000, 1000000)).Count() > 0) // Check if element exists
                 {
                     x = false;
                 }
             }
         }
     }
 }