public IActionResult Register(Students student, Teachers teachers) { if (!ModelState.IsValid) { return(View()); } string id = Request.Form["userid"]; string name = Request.Form["username"]; string password = Request.Form["password"]; string rode = Request.Form["rode"]; if (rode.Equals("学生")) { student.student_id = id; student.student_name = name; student.student_password = password; student.student_time = DateTime.Now; userContent.Students.Add(student); userContent.SaveChanges(); RedirectToAction("Home", "Login"); } else if (rode.Equals("教师")) { teachers.Teacher_id = id; teachers.Teacher_name = name; teachers.Teacher_password = password; teachers.Teacher_time = DateTime.Now; userContent.Teachers.Add(teachers); userContent.SaveChanges(); RedirectToAction("Home", "Login"); } return(View()); }
public IActionResult Setting(Students student) { ViewBag.name = HttpContext.Session.GetString("name"); ViewBag.img = HttpContext.Session.GetString("img"); var t = userContent.Students.FirstOrDefault(b => b.student_id == student.student_id); if (student.imgfile != null) { IFormFile file = student.imgfile; var fileName = file.FileName; var filetype = Path.GetExtension(fileName); var bbb = Path.GetFileNameWithoutExtension(fileName); // fileName = bbb + filetype; fileName = hostingEnv.WebRootPath + "\\image" + $@"\{fileName}"; var fileName1 = "/image" + $@"/{bbb}" + filetype; using (FileStream fs = System.IO.File.Create(fileName)) { file.CopyTo(fs); fs.Flush(); } t.student_img = fileName1; HttpContext.Session.SetString("img", fileName1); } var dec = Request.Form["Dec"]; t.student_name = student.student_name; t.student_email = student.student_email; t.student_dec = dec; userContent.SaveChanges(); ViewBag.info = t; return(View()); }
public IActionResult ClassSetting(Course course) { ViewBag.name = HttpContext.Session.GetString("name"); ViewBag.img = HttpContext.Session.GetString("img"); try { userContent.Course.Add(course); userContent.SaveChanges(); List <Course> courses = new List <Course>(); courses = userContent.Course.ToList(); ViewBag.course = courses; } catch { } // RedirectToAction("ClassSetting", "Teacher"); return(View()); }
public static void test() { EOrderLine order = null; EMemberInfo mi = null; using (TransactionScope sc = new TransactionScope()) { using (UserContent db = new UserContent()) { string openId = "orKUAw16WK0BmflDLiBYsR-Kh5bE"; db.UpdateToMemberLevel2(openId); mi = db.GetMemberInfoByOpenId(openId); db.SaveChanges(); } using (OrderContent odb = new OrderContent()) { order = odb.UpdateToPaidOrder(mi); } } }
public void DeleteClass(int id) { try { var data = userContent.Course.FirstOrDefault(b => b.Class_ID == id); userContent.Course.Remove(data); userContent.SaveChanges(); } catch { Console.WriteLine("error"); } }
/************************************************************************************** * Function Name : ArticlesIndexController * Description : Constructor, add some articles to database * Caution : Parameter : UserContent context -> Database context object * Return : ArticlesIndexController object **************************************************************************************/ public ArticlesIndexController(UserContent context) { _context = context; if (_context.Article.Count() == 0) { _context.Article.Add(new Article { Title = "a", Date = new DateTime(2019, 05, 06), Author = "test1", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "b", Date = new DateTime(2019, 05, 06), Author = "test", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "c", Date = new DateTime(2019, 05, 06), Author = "test2", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "d", Date = new DateTime(2019, 05, 06), Author = "test3", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "e", Date = new DateTime(2019, 05, 06), Author = "test1", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "f", Date = new DateTime(2019, 05, 06), Author = "test2", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "g", Date = new DateTime(2019, 05, 06), Author = "test1", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "h", Date = new DateTime(2019, 05, 06), Author = "test1", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "i", Date = new DateTime(2019, 05, 06), Author = "test1", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "j", Date = new DateTime(2019, 05, 06), Author = "test2", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "k", Date = new DateTime(2019, 05, 06), Author = "test2", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "l", Date = new DateTime(2019, 05, 06), Author = "test3", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "m", Date = new DateTime(2019, 05, 06), Author = "test4", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "n", Date = new DateTime(2019, 05, 06), Author = "test", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "aaa", Date = new DateTime(2019, 05, 06), Author = "test", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "aaa", Date = new DateTime(2019, 05, 06), Author = "test", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "aaa", Date = new DateTime(2019, 05, 06), Author = "test", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "aaa", Date = new DateTime(2019, 05, 06), Author = "test", Content = "aaa", AttachFile = "aaa" }); _context.Article.Add(new Article { Title = "aaa", Date = new DateTime(2019, 05, 06), Author = "test", Content = "aaa", AttachFile = "aaa" }); _context.SaveChanges(); } }