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.ToString(); dbItem.Longitude = item.Longitude.ToString(); _context.IPDetails.Add(dbItem); _context.SaveChanges(); }
private static void UpdateJobDetails(int itemsInserted, Guid jobId, IPDetailsDBEntities context) { var jobItem = context.IPJobs.FirstOrDefault(n => n.Id == jobId.ToString()); jobItem.Progress += itemsInserted; context.SaveChanges(); }
private static void FinalizeJobDetails(JobStatusEnum status, Guid jobId, IPDetailsDBEntities context) { var jobItem = context.IPJobs.FirstOrDefault(n => n.Id == jobId.ToString()); jobItem.FinishedOn = DateTime.Now; jobItem.Status = (int)status; if (status == JobStatusEnum.Completed) { jobItem.Progress = jobItem.Total; //all items are updated } context.SaveChanges(); }
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(); }