Пример #1
0
        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);
            }
        }
Пример #2
0
        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
            {
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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
            {
            }
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
        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
            {
            }
        }