Esempio n. 1
0
 public Region this[string key]
 {
     get
     {
         Region l = null;
         if (!TryGetValue(key, out l))
         {
             throw new ArgumentOutOfRangeException();
         }
         return(l);
     }
     set
     {
         Region l = null;
         if (!TryGetValue(key, out l))
         {
             Add(key, value);
         }
         else
         {
             if (value == null || value.ID == 0)
             {
                 throw new ArgumentException("Region is invalid.");
             }
             context.RegionDictionaryElements.Where(el => el.RegionID == l.ID).First().RegionID = value.ID;
             context.SaveChanges();
         }
     }
 }
Esempio n. 2
0
        public League this[Tuple <string, Region, Sport> key]
        {
            get
            {
                League l = null;
                if (!TryGetValue(key, out l))
                {
                    throw new ArgumentOutOfRangeException();
                }
                return(l);
            }

            set
            {
                League l = null;
                if (!TryGetValue(key, out l))
                {
                    Add(key, value);
                }
                else
                {
                    if (value == null || value.ID == 0)
                    {
                        throw new ArgumentException("League is invalid.");
                    }

                    context.LeagueDictionaryElements.Where(el => el.Name == key.Item1 && el.SportID == key.Item2.ID && el.RegionID == key.Item3.ID).First().LeagueID = value.ID;
                    context.SaveChanges();
                }
            }
        }
Esempio n. 3
0
 public static void Enqueue(CompareLeague item)
 {
     using (VilkaEntities context = new VilkaEntities())
     {
         context.CompareLeagues.Add(item);
         context.SaveChanges();
     }
 }