コード例 #1
0
        public List <Ipuzzle> Get(int id, string connectionID, Boolean isReset = false)
        {
            List <Ipuzzle> list       = null; // Şişme ihtimali var. Sürekli Cmd+R mesela.
            List <Ipuzzle> cloneList  = null;
            List <Ipuzzle> randomList = null; //Enson gönderilen lİST

            if (isReset)
            {
                cache.Clear();
            }
            if (!cache.ContainsKey(connectionID))
            {
                using (PuzzleDataContext dbContext = new PuzzleDataContext())
                {
                    //Her Seferinde Random Almak lazımdı. Ama Hem Main hem de Control aynı Random List'i almalı.
                    Random rnd = new Random();
                    list = dbContext.FrozenPuzzle.Where(fr => fr.RefCategoryID == id)
                           .OrderBy <Ipuzzle, int>((item) => rnd.Next()).Take(6).ToList <Ipuzzle>();
                    cloneList = CloneList <Ipuzzle>(list.OrderBy <Ipuzzle, int>((item) => rnd.Next()).ToList());
                    cloneList.ForEach(f => f.ID = CloneID(f.ID)); //UniqID yapmaz isek kartları ayırt edemeyiz

                    list.AddRange(cloneList);

                    randomList = list.OrderBy <Ipuzzle, int>((item) => rnd.Next()).Take(12).ToList <Ipuzzle>();

                    cache.Add(connectionID, randomList);
                }
            }
            else
            {
                randomList = cache[connectionID];
                cache.Remove(connectionID);
            }
            return(randomList);
        }
コード例 #2
0
 public List <PuzzleCategory> Get()
 {
     using (PuzzleDataContext dbContext = new PuzzleDataContext())
     {
         return(dbContext.PuzzleCategory.ToList());
     }
 }