コード例 #1
0
        public ActionResult Create(CmTeacher cmteacher)
        {
            if (ModelState.IsValid)
            {
                context.CmTeachers.Add(cmteacher);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.Possibleusers = context.Users;
            ViewBag.PossibleclUniversities = context.ClUniversities;
            return View(cmteacher);
        }
コード例 #2
0
        public ActionResult CreateTeacher(User user, string teacherTitle, int clUniversityId)
        {
            if (ModelState.IsValid)
            {
                context.Users.Add(user);

                CmTeacher newTeacher = new CmTeacher();
                newTeacher.userID = user.ID;//TODO - probably
                newTeacher.clUniversityId = clUniversityId;
                if(teacherTitle.Equals("no")){
                    newTeacher.title = "";
                } else {
                    newTeacher.title = teacherTitle;
                }

                context.CmTeachers.Add(newTeacher);
                context.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(user);
        }
コード例 #3
0
 public ActionResult Edit(CmTeacher cmteacher)
 {
     if (ModelState.IsValid)
     {
         context.Entry(cmteacher).State = EntityState.Modified;
         context.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.Possibleusers = context.Users;
     ViewBag.PossibleclUniversities = context.ClUniversities;
     return View(cmteacher);
 }