private static void UpdateIpDetailList(IDictionary <string, IPDetailsModel> items, IPDetailsDBEntities context)
        {
            foreach (KeyValuePair <string, IPDetailsModel> item in items)
            {
                IPDetail dbItem = context.IPDetails.FirstOrDefault(n => n.Ip == item.Key);

                dbItem.Ip        = item.Key;
                dbItem.City      = item.Value.City;
                dbItem.Country   = item.Value.City;
                dbItem.Latitude  = item.Value.Latitude.ToString();
                dbItem.Longitude = item.Value.Longitude.ToString();
            }

            context.SaveChanges();
        }
Esempio n. 2
0
        public void AddIpDetails(string ip, IPDetailsModel item)
        {
            var dbItem = new IPDetail();

            dbItem.Ip        = ip;
            dbItem.City      = item.City;
            dbItem.Country   = item.Country;
            dbItem.Continent = item.Continent;
            dbItem.Latitude  = item.Latitude.GetValueOrDefault().ToString();
            dbItem.Longitude = item.Longitude.GetValueOrDefault().ToString();

            _context.IPDetails.Add(dbItem);

            _context.SaveChanges();
        }