コード例 #1
0
 public List <Country> GetAllCountries()
 {
     using (var context = new FlagCheckerContext())
     {
         return(context.Countries.ToList());
     }
 }
コード例 #2
0
 public Country GetCountryById(int id)
 {
     using (var context = new FlagCheckerContext())
     {
         return(context.Countries.FirstOrDefault(u => u.Id == id));
     }
 }
コード例 #3
0
        public void Save(string uid, DateTime date, byte[] countries)
        {
            using (var context = new FlagCheckerContext())
            {
                var entity = context.Set <Share>();
                var share  = new Share {
                    Uid = uid, Countries = countries, Date = date
                };

                entity.Add(share);
                context.SaveChanges();
            }
        }
コード例 #4
0
        public Share GetCountriesByUid(string uid)
        {
            Share countries = new Share();

            using (var context = new FlagCheckerContext())
            {
                var shares = context.Shares.FirstOrDefault(x => x.Uid == uid);
                if (shares != null)
                {
                    countries = shares;
                }
            }
            return(countries);
        }
コード例 #5
0
        public List <Country> GetCountriesByIds(List <string> idList)
        {
            var list = new List <Country>();

            using (var context = new FlagCheckerContext())
            {
                foreach (var element in idList)
                {
                    list.Add(context.Countries.FirstOrDefault(u => u.Id.ToString() == element));
                }

                return(list);
            }
        }