static void Main(string[] args) { var optionsBuilder = new DbContextOptionsBuilder <EstateWebDbContext>(); optionsBuilder.UseSqlServer("Server=NGOCHAHA; Database= EstateDb; Integrated Security=true;"); _context = new EstateWebDbContext(optionsBuilder.Options); GetDataProvince(); //GetDataDistrict(); //GetMultiData(); }
static void GetDataProvince() { string link = "https://alonhadat.com.vn/dang-tin-nha-dat.html"; HtmlWeb htmlWeb = new HtmlWeb(); { }; HtmlDocument document = htmlWeb.Load(link); var selectboxProvince = document.GetElementbyId("ctl00_content_tinh").ChildNodes; List <Province> lstProvince = new List <Province>(); foreach (var item in selectboxProvince) { if (item.Name == "option" && item.Attributes["value"].Value != "0") { lstProvince.Add(new Province { Id = int.Parse(item.Attributes["value"].Value), Name = HttpUtility.HtmlDecode(item.InnerText) }); Console.WriteLine(item.Attributes["value"].Value); Console.WriteLine(HttpUtility.HtmlDecode(item.InnerText)); } } var optionsBuilder = new DbContextOptionsBuilder <EstateWebDbContext>(); optionsBuilder.UseSqlServer("Server=NGOCHAHA; Database= Movie; Integrated Security=true;"); var _context = new EstateWebDbContext(optionsBuilder.Options); _context.Provinces.AddRange(lstProvince); _context.SaveChanges(); GetDataDistrict(); Console.ReadKey(); }
public EchoBot(EstateWebDbContext movie) { _movie = movie; }
//private readonly ILogger<HomeController> _logger; //public HomeController(ILogger<HomeController> logger) //{ // _logger = logger; //} public HomeController(EstateWebDbContext estaweb) { _estaweb = estaweb; }
public MovieController(EstateWebDbContext movie) { _movie = movie; }