コード例 #1
0
        public ActionResult Create(Student student)
        {
            if (ModelState.IsValid)
            {
                db.Student.AddObject(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
コード例 #2
0
        public ActionResult Create(User model)
        {
            if (ModelState.IsValid)
            {
                Student student = new Student()
                {
                    StudentId   = model.StudentId,
                    StudentName = model.StudentName,
                    MobileNo    = model.MobileNo,
                    Class       = model.Class,
                    Gender      = model.Gender,
                    LoginId     = model.LoginId
                };
                demoEntities.Students.Add(student);
                demoEntities.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }