public List <Country> GetAllCountries() { using (var context = new FlagCheckerContext()) { return(context.Countries.ToList()); } }
public Country GetCountryById(int id) { using (var context = new FlagCheckerContext()) { return(context.Countries.FirstOrDefault(u => u.Id == id)); } }
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(); } }
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); }
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); } }