public ActionResult ChangeCat() { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Student)) { return(RedirectToAction("PermitionEr", "Error")); } string text1 = System.IO.File.ReadAllText(Server.MapPath("~/ClassData.json")); JObject text = JObject.Parse(text1); Grade b = new Grade( (int)text["Class1"], (int)text["Class2"], (int)text["Class3"] ); StudentsModel model = new StudentsModel() { category = db2.Category.ToList(), userCategory = from a in db.Categories.ToList() where a.CatUName == int.Parse(Session["UserNo"].ToString()) select a, grade = b }; return(View(model)); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult upgrade(string UserId, string UserClass) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Admin)) { return(RedirectToAction("PermitionEr", "Error")); } var result = from a in db.Users.ToList() where a.UserId == UserId select a; foreach (var item in result) { item.UserClass = UserClass; db.Entry(item).State = EntityState.Modified; db.SaveChanges(); } return(Redirect("/home/")); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult ChangePw(string UserId, string UserPrePw, string UserChPw) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Student)) { return(RedirectToAction("PermitionEr", "Error")); } UserPrePw = Encryption.Encode(UserPrePw); var a = db4.Users.First(e => e.UserId == UserId); if (a.UserPassword == UserPrePw) { a.UserPassword = Encryption.Encode(UserChPw); db4.SaveChanges(); } return(View()); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult ClassNoti(string ClassNotiText, string ClassNotiAttribute, string[] checkbox) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } string str = null; for (int i = 0; i < checkbox.Length; i++) { ClassNoti a = new ClassNoti() { ClassNotiAttribute = ClassNotiAttribute, ClassNoticlass = checkbox[i], ClassNotiText = ClassNotiText, ClassNotiTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") }; db3.ClassNotis.Add(a); } db3.SaveChanges(); return(View()); } catch { return(RedirectToAction("LoginEr", "Error")); } }
// GET: Images public ActionResult Index(int?id) { try { if (Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Admin) != true) { return(Redirect("~/users/error")); } } catch (Exception e) {} /*try * { * if (string.Compare(Session["UserClass"].ToString(), "admin") != 0) * { * return Redirect("~/home/ClassError"); * } * } * catch (Exception E) * { * return Redirect("~/users/error"); * }*/ if (id == null) { id = 1; } int a = (int)id; var query = from m in db.Image.ToList() select m; var result = query.Skip((a - 1) * 10).Take(10); ViewBag.Page = id; return(View(result)); }
public ActionResult ViewDB(string DbContext) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Admin)) { return(RedirectToAction("PermitionEr", "Error")); } HomeworkDBContext homeworkDB = new HomeworkDBContext(); CommentDBContext commentDB = new CommentDBContext(); UserDBContext userDB = new UserDBContext(); CategoryDBContext categoryDB = new CategoryDBContext(); UserCategoriesDBcontext userCategoriesDB = new UserCategoriesDBcontext(); NoteCatDBContext noteCatDB = new NoteCatDBContext(); ClassNotiDBcontext classNotiDB = new ClassNotiDBcontext(); return(View()); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult DeleteCat(int id) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } var item = from a in db.Category.ToList() where a.CatId == id select a; var item2 = from a in db2.Categories.ToList() where a.CatUSelect == id select a; foreach (var a in item2)//사용자 카테고리 삭제 { db2.Categories.Remove(a); db2.SaveChanges(); } db.Category.Remove(item.First());//카테고리 삭제 db.SaveChanges(); return(Redirect("~/Teacher/AddCat")); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult ViewDB() { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Admin)) { return(RedirectToAction("PermitionEr", "Error")); } return(View()); } catch { return(RedirectToAction("LoginEr", "Error")); } }
// GET: Homework/Create public ActionResult Create() { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } return(View(db2.Category.ToList())); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult ClassNoti() { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } return(View("ClassNoti")); } catch { return(RedirectToAction("LoginEr", "Error")); } }
// POST: Homework/Delete/5 public ActionResult Delete(int id) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } Homework homework = db.Homework.First(a => a.NoteNo == id); _DelHomeworks(homework); return(RedirectToAction("Index")); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult Create([Bind(Include = "NoteNo,Subject,T_Name,Contents,Title,Date")] Homework homework, string[] checkbox, string[] checkbox2) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } if (ModelState.IsValid) { homework.T_Name = Session["UserName"].ToString(); db.Homework.Add(homework); db.SaveChanges(); for (int i = 0; i < checkbox.Length; i++) { db3.NoteCat.Add(new NoteCat() { NoteNo = homework.NoteNo, CatAttribute = checkbox[i] }); Noti(checkbox[i], homework); } for (int i = 0; i < checkbox2.Length; i++) { db5.NoteClass.Add(new NoteClass { NoteId = homework.NoteNo, NoteClasses = int.Parse(checkbox2[i]) }); } db5.SaveChanges(); db3.SaveChanges(); } return(Redirect("~/homework")); } catch (FirebaseException e) { return(Redirect("~/Error/CustomEr/" + e.Message)); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult AddCat([Bind(Include = "CatId,CatName,CatAttribute")] Category category) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } if (ModelState.IsValid) { db.Category.Add(category); db.SaveChanges(); return(View(db.Category.ToList())); } return(View(db.Category.ToList())); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult ChangeCat(string[] checkbox, string radio) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Student)) { return(RedirectToAction("PermitionEr", "Error")); } var ab = from a in db.Categories.ToList() where a.CatUName == int.Parse(Session["UserNo"].ToString()) select a; foreach (var item in ab) { db.Categories.Remove(item); db.SaveChanges(); } SelectedCategory abc = new SelectedCategory() { CatUName = int.Parse(Session["UserNo"].ToString()), }; for (int i = 0; i < checkbox.Length; i++) { abc.CatUSelect = int.Parse(checkbox[i]); db.Categories.Add(abc); db.SaveChanges(); } int d = int.Parse(Session["UserNo"].ToString()); var b = db4.Users.First(c => c.UserNo == d); b.UserGroup = int.Parse(radio); db4.SaveChanges(); db.SaveChanges(); Session["UserGr"] = radio; return(RedirectToAction("Settings")); } catch { return(RedirectToAction("LoginEr", "Error")); } }
public ActionResult Create([Bind(Include = "NoteNo,Subject,T_Name,Contents,Title,Date")] Homework homework, string[] checkbox) { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } if (ModelState.IsValid) { homework.T_Name = Session["UserName"].ToString(); db.Homework.Add(homework); db.SaveChanges(); for (int i = 0; i < checkbox.Length; i++) { db3.NoteCat.Add(new NoteCat() { NoteNo = homework.NoteNo, CatAttribute = checkbox[i] }); } db3.SaveChanges(); /*Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); * IPEndPoint iPEndPoint = new IPEndPoint(IPAddress.Parse("110.10.38.94"), 1503); * client.Connect(iPEndPoint); * return RedirectToAction("Index");*/ } return(Redirect("~/homework")); } catch { return(RedirectToAction("LoginEr", "Error")); } }
// GET: Homework/Create public ActionResult Create() { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { return(RedirectToAction("PermitionEr", "Error")); } string text1 = System.IO.File.ReadAllText(Server.MapPath("~/ClassData.json")); JObject text = JObject.Parse(text1); Grade a = new Grade( (int)text["Class1"], (int)text["Class2"], (int)text["Class3"] ); return(View(new GradeData(a, db2.Category.ToList()))); } catch { return(RedirectToAction("LoginEr", "Error")); } }
// GET: Homework public ActionResult Index()//과제확인 리스트 { try { if (!Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Student)) { return(RedirectToAction("PermitionEr", "Error")); } DelHomeworks();//유저가 리스트를 확인하면 시간이 지난 과제들을 삭제 var userlist = from a in db4.Categories.ToList() where a.CatUName == int.Parse(Session["UserNo"].ToString()) select a;//유저 var list = from a in db.Homework.ToList() orderby a.Date select a; var noteclasslist = db5.NoteClass.ToList(); List <Homework> result = new List <Homework>();//과제 리스트 불러오기 int usergroup = int.Parse(Session["UserGr"].ToString()); foreach (var item in list) { bool check = false; var catlist = from a in db3.NoteCat.ToList() where a.NoteNo == item.NoteNo select a; foreach (var item2 in noteclasslist) { if (item2.NoteClasses == usergroup) { check = true; break; } if (check) { break; } } if (!check && !Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { continue; } check = false; foreach (var item2 in userlist) { foreach (var item3 in catlist) { if (int.Parse(item3.CatAttribute) == item2.CatUSelect) { check = true; break; } } if (check) { break; } } if (check || Authen.Certification(Session["UserClass"].ToString(), Authen.UserClass.Teacher)) { result.Add(item); } } return(View(result)); //return View(db.Homework.ToList()); } catch { return(RedirectToAction("LoginEr", "Error")); } }