예제 #1
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName")] Students students)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(students);
                UserClasses user = new UserClasses();
                user.fk_Class = (int)Session["CurrentClassId"];
                user.fk_User  = db.Students.Max(x => x.Id);
                db.UserClasses.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(students));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "Id,Name,Section,StartTime,EndTime,Length,Days")] Class @class)
        {
            if (ModelState.IsValid)
            {
                db.Classes.Add(@class);
                UserClasses user = new UserClasses();
                user.fk_Class = db.Classes.Max(x => x.Id);
                user.fk_User  = Convert.ToInt32(Session["UserID"]);
                db.UserClasses.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(@class));
        }