public void AddSiteList(string jsonHtml) { try { var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <SexSpider> >(jsonHtml); using (var db = new SexSpiderDbContext()) { db.SexSpider.AddRange(jsonObject); db.SaveChanges(); } } catch (Exception ex) { log.Error(ex.Message); } }
public void AddSiteList(string jsonHtml) { try { var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SiteListViewModel> >(jsonHtml); var models = AutoMapper.Mapper.Map <List <SiteListViewModel>, List <SexSpider> >(jsonObject); using (var db = new SexSpiderDbContext()) { db.SexSpider.AddRange(models); db.SaveChanges(); } } catch { } }
public void RemoveSiteList(string jsonHtml) { try { var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <SexSpider> >(jsonHtml); using (var db = new SexSpiderDbContext()) { jsonObject.ToList().ForEach(s => { db.SexSpider.Remove(db.SexSpider.Where(a => a.SiteId == s.SiteId).FirstOrDefault()); db.SaveChanges(); }); } } catch (Exception ex) { log.Error(ex.Message); } }
public void RemoveSiteList(string jsonHtml) { try { var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SiteListViewModel> >(jsonHtml); var models = AutoMapper.Mapper.Map <List <SiteListViewModel>, List <SexSpider> >(jsonObject); using (var db = new SexSpiderDbContext()) { models.ForEach(s => { db.SexSpider.Remove(db.SexSpider.Where(a => a.SiteId == s.SiteId).FirstOrDefault()); db.SaveChanges(); }); } } catch { } }
public void UpdateSiteList(string jsonHtml) { try { var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject <IEnumerable <SexSpider> >(jsonHtml); using (var db = new SexSpiderDbContext()) { jsonObject.ToList().ForEach(s => { db.SexSpider.Attach(s); DbEntityEntry <SexSpider> entry = db.Entry(s); entry.State = EntityState.Modified; db.SaveChanges(); }); } } catch (Exception ex) { log.Error(ex.Message); } }
public void UpdateSiteList(string jsonHtml) { try { var jsonObject = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SiteListViewModel> >(jsonHtml); var models = AutoMapper.Mapper.Map <List <SiteListViewModel>, List <SexSpider> >(jsonObject); using (var db = new SexSpiderDbContext()) { models.ForEach(s => { db.SexSpider.Attach(s); DbEntityEntry <SexSpider> entry = db.Entry(s); entry.State = EntityState.Modified; db.SaveChanges(); }); } } catch { } }