public bool IsInClass(Class cl, string username) { foreach(var i in cl.Users) { if (i.Username == username) return true; } return false; }
public ActionResult CreateClass(Class newClass) { string username = User.Identity.Name; db.Classes.AddObject(newClass); db.SaveChanges(); ViewBag.LecturerID = new SelectList(userRep.GetAllLecturer(), "UserName", "UserName", newClass.LecturerID); ViewBag.SubjectID = new SelectList(db.Subjects, "ID", "Name", newClass.SubjectID); ViewBag.SchoolYear = new SelectList(new MyClass[]{new MyClass{Value=1, Text="2011-2012"}, new MyClass{Value=2,Text="2012-2013"}, new MyClass{Value=3,Text="2013-2014"}}, "Text", "Text", newClass.SchoolYear); ViewBag.Term = new SelectList(new MyClass[]{new MyClass{Value=1, Text="HK I"}, new MyClass{Value=2, Text="HK II"}, new MyClass{Value=3, Text="HK III"}}, "Text", "Text", newClass.Term); return View(); }
public ActionResult DsProblemPartial(Class cla) { List<Problem> ds = new List<Problem>(); foreach (var i in db.Problems) { foreach (var j in i.Classes) { if (j.ID == cla.ID) ds.Add(i); } } return PartialView("DSProblemPartial", ds); }
/// <summary> /// Create a new Class object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="subjectID">Initial value of the SubjectID property.</param> /// <param name="group">Initial value of the Group property.</param> /// <param name="term">Initial value of the Term property.</param> /// <param name="schoolYear">Initial value of the SchoolYear property.</param> /// <param name="lecturerID">Initial value of the LecturerID property.</param> /// <param name="isDeleted">Initial value of the IsDeleted property.</param> public static Class CreateClass(global::System.Int32 id, global::System.String subjectID, global::System.String group, global::System.String term, global::System.String schoolYear, global::System.String lecturerID, global::System.Boolean isDeleted) { Class @class = new Class(); @class.ID = id; @class.SubjectID = subjectID; @class.Group = group; @class.Term = term; @class.SchoolYear = schoolYear; @class.LecturerID = lecturerID; @class.IsDeleted = isDeleted; return @class; }
/// <summary> /// Deprecated Method for adding a new object to the Classes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToClasses(Class @class) { base.AddObject("Classes", @class); }