Exemplo n.º 1
0
        public ActionResult Create(Student student)
        {
            try
            {
                if (ModelState.IsValid)

                {
                    db.Students.Add(student);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                return View(student);
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 2
0
        public ActionResult Delete(int? id,Student st)
        {
            try
            {
                Student student=new Student();
                if (ModelState.IsValid)
                {
                    if (id == null)
                        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                     student = db.Students.Find(id);
                    if (student == null)
                        return HttpNotFound();

                    db.Students.Remove(student);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                return View(student);
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 3
0
        public static void SaveStudent(Student newStudent)
        {
            ArrayOfStudent students = XmlFileUtil.Deserialize();
            Student oldStudent = students.studentsList.Find(delegate(Student s)
            {
                return (s.StudentID == newStudent.StudentID);
            });
            students.studentsList.Remove(oldStudent);
            students.studentsList.Add(newStudent);

            XmlSerializer serializer = new XmlSerializer(typeof(ArrayOfStudent));

            using (StreamWriter writer = new StreamWriter(xmlpath))
            {
                serializer.Serialize(writer, students);
            }
        }
Exemplo n.º 4
0
 public ActionResult Edit(int id, Student student)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Entry(student).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return RedirectToAction("Index");
         }
         return View(student);
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 5
0
 partial void DeleteStudent(Student instance);
Exemplo n.º 6
0
 partial void UpdateStudent(Student instance);
Exemplo n.º 7
0
 partial void InsertStudent(Student instance);