public IActionResult Learn(int id) { var model = db.lessons.Find(id); model.viewed += 1; db.SaveChanges(); return(View(model)); }
private void CreateChudeSample(EnglishDbContext context) { if (context.ChuDes.Count() == 0) { List <ChuDe> listChuDe = new List <ChuDe>() { new ChuDe() { TenChuDe = "Reading" }, new ChuDe() { TenChuDe = "Speaking" }, new ChuDe() { TenChuDe = "Listening" }, new ChuDe() { TenChuDe = "Writing" } }; context.ChuDes.AddRange(listChuDe); context.SaveChanges(); } }
public async Task <bool> InsertAsync(int _from, int _to) { // From Web for (int p = _from; p <= _to; p++) { var url = $"http://tratu.coviet.vn/hoc-tieng-anh/cap-cau-song-ngu/vietgle-tra-tu/tat-ca/trang-{p}.html"; var web = new HtmlWeb(); var doc = web.Load(url); var sentence_nodes = doc.DocumentNode.SelectNodes("//*[@id='ctl00_ContentPlaceHolderMain_ctl00']/ul"); var sentences = new List <Lesson>(); foreach (var item in sentence_nodes) { var english_node = item.FirstChild; var english = english_node.InnerHtml; var vietnam_node = english_node.NextSibling; var vietnam = vietnam_node.InnerHtml; sentences.Add(new Lesson() { date_created = DateTime.Now, date_modified = DateTime.Now, deleted = 0, english_text = english, keywords = "", title = english, vietnamese_text = vietnam, }); } db.lessons.AddRange(sentences); db.SaveChanges(); await Task.Delay(100); } return(true); }
private void CreateLoaiCauHoiSample(EnglishDbContext context) { if (context.LoaiCauHois.Count() == 0) { List <LoaiCauHoi> listLoaiCauHoi = new List <LoaiCauHoi>() { new LoaiCauHoi() { NoiDung = "Multiple-choice" }, new LoaiCauHoi() { NoiDung = "Essay" }, }; context.LoaiCauHois.AddRange(listLoaiCauHoi); context.SaveChanges(); } }
private void CreateCauHoiSample(EnglishDbContext context) { if (context.CauHois.Count() == 0) { List <CauHoi> listCauHoi = new List <CauHoi>() { new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" }, new CauHoi() { LoaiCauHoi_ID = 1, BaiDocNghe_ID = 1, ChuDe_ID = 3, NoiDung = "Noi dung cau hoi", DapAn = "Dap an cau hoi" } }; context.CauHois.AddRange(listCauHoi); context.SaveChanges(); } }