/// <summary>
        /// Addtoes the student.
        /// </summary>
        /// <param name="student">The student.</param>
        /// <param name="course">The course.</param>
        public static void AddtoStudent(Student student, Cours course)
        {
            if (!course.Students.Contains(student))
                course.Students.Add(student);

            db.SaveChanges();
        }
 /// <summary>
 /// Adds the academy ID.
 /// </summary>
 /// <param name="student">The student.</param>
 public static void AddAcademyID(Student student)
 {
     string code = (student.ID + "_" + student.FirstName.Substring(0, 2) +
                   student.LastName.Substring(0, 2)).ToUpper();
     student.AcademyID = code;
     db.SaveChanges();
 }
        public ActionResult Create(Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.AddObject(student);
                db.SaveChanges();
                return PartialView("GridData", new Student[] { student });
            }

            return PartialView("Edit", student);
        }
        public ActionResult Edit(Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Attach(student);
                db.ObjectStateManager.ChangeObjectState(student, EntityState.Modified);
                db.SaveChanges();
                return PartialView("GridData", new Student[] { student });
            }

            return PartialView(student);
        }
        /// <summary>
        /// Creates the specified first name.
        /// </summary>
        /// <param name="firstName">The first name.</param>
        /// <param name="lastName">The last name.</param>
        /// <param name="email">The email.</param>
        /// <returns></returns>
        public static Student Create(string firstName, string lastName, string email)
        {
            Student c = new Student();
            c.FirstName = firstName;
            c.LastName = lastName;
            c.Email = email;

            db.AddToStudents(c);
            db.SaveChanges();

            return c;
        }
 /// <summary>
 /// Creates the specified Submission.
 /// </summary>
 /// <param name="student">The student.</param>
 /// <param name="topic">The topic.</param>
 /// <param name="uploadDate">The upload date.</param>
 /// <param name="Extension">Type of the MIME.</param>
 /// <param name="fileData">The file data.</param>
 public static void Create(Student student, Topic topic, Cours course, DateTime uploadDate, string Extension, string filePath)
 {
     Submission s = new Submission();
     s.Student = student;
     s.Cours = course;
     s.Topic = topic;
     s.UploadDate = uploadDate;
     s.Extension = Extension;
     s.FilePath = filePath.Trim();
     db.Submissions.AddObject(s);
     db.SaveChanges();
 }
        //
        // GET: /Student/Edit/5
        public ActionResult Edit(int id)
        {
            Student student = new Student();

            try
            {
               student = db.Students.Single(s => s.ID == id);
            }
            catch (Exception)
            {

            }
            return PartialView(student);
        }
 /// <summary>
 /// Adds student to course.
 /// </summary>
 /// <param name="student">The student.</param>
 /// <param name="course">The course.</param>
 public static void AddToCourse(Student student, Cours course)
 {
     student.Courses.Add(course);
     db.SaveChanges();
 }
 /// <summary>
 /// Updates the specified Student.
 /// </summary>
 /// <param name="Student">The Student.</param>
 /// <param name="firstName">Student's first Name</param>
 /// <param name="lastName">The Student's last Name</param>
 public static void Update(Student student, string firstName, string lastName)
 {
     student.FirstName = firstName;
     student.LastName = lastName;
     db.SaveChanges();
 }
 public static void AddStudentToCourse(Student student, Cours course)
 {
     course.Students.Add(student);
     db.SaveChanges();
 }
 /// <summary>
 /// Create a new Student object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 public static Student CreateStudent(global::System.Int32 id, global::System.String firstName, global::System.String lastName, global::System.String email)
 {
     Student student = new Student();
     student.ID = id;
     student.FirstName = firstName;
     student.LastName = lastName;
     student.Email = email;
     return student;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Students EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStudents(Student student)
 {
     base.AddObject("Students", student);
 }