示例#1
0
        public ActionResult Create(Teacher model)
        {
            XCourseContext db = new XCourseContext();

            Teacher teacher = new Teacher();

            teacher.FirstName   = model.FirstName;
            teacher.LastName    = model.LastName;
            teacher.Proficiency = model.Proficiency;

            try
            {
                db.Entry(teacher).State = System.Data.Entity.EntityState.Added;
                db.SaveChanges();
                return(RedirectToAction("Index"));

                //List<Teacher> teacherList = db.Teachers.ToList();
                //return View("Index", teacherList);
            }
            catch (Exception)
            {
                return(View(model));
                //return RedirectToAction("Create");
            }
        }
示例#2
0
        public ActionResult Create(Student model)
        {
            Student student = new Student();

            student.FirstName   = model.FirstName;
            student.LastName    = model.LastName;
            student.DateOfBirth = model.DateOfBirth;
            student.TeacherId   = model.TeacherId;

            db = new XCourseContext();

            try
            {
                db.Entry(student).State = System.Data.Entity.EntityState.Added;
                db.SaveChanges();

                TempData["ResultMessage"] = "Kayıt işlemi başarılı";
                TempData["StudentEntity"] = student;
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View(model));
            }
        }
示例#3
0
        public ActionResult DeleteConfirmed(int id)
        {
            XCourseContext db = new XCourseContext();

            Teacher teacher = db.Teachers.Find(id);

            try
            {
                db.Entry(teacher).State = System.Data.Entity.EntityState.Deleted;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception)
            {
                return(View(teacher));
            }
        }