예제 #1
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Geometry,Addition,Subtraction,TotalScore,Username")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
예제 #2
0
        public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Email,Username,Password,ConfirmPassword")] Teacher teacher)
        {
            while (db.Students.Find(teacher.Id) != null)
            {
                teacher.Id++;
            }

            if (ModelState.IsValid)
            {
                db.Entry(teacher).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(teacher));
        }
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Geometry,Addition,Subtraction,TotalScore,Username")] Student student)
        {
            while (db.Students.Find(student.Id) != null)
            {
                student.Id++;
            }
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Email,Username,Password,ConfirmPassword")] Teacher teacher)
        {
            //Add teacher to new row in the database. This loop is needed to prevent database from crashing.
            while (db.Teachers.Find(teacher.Id) != null)
            {
                teacher.Id++;
            }

            //Adds new teacher to the database, clears input fields, then creats a feedback message upon successfuly registration.
            if (ModelState.IsValid)
            {
                using (Kismet_InfoEntities db = new Kismet_InfoEntities())
                {
                    db.Teachers.Add(teacher);
                    db.SaveChanges();
                }
                ModelState.Clear();
                ViewBag.Message = teacher.FirstName + " " + teacher.LastName + " successfully registered.";
            }

            return(View(teacher));
        }
예제 #5
0
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Geometry,Addition,Subtraction,TotalScore,Username")] Student student)
        {
            //Adds student to a new row in the database. Without this while loop the application crashes.
            while (db.Students.Find(student.Id) != null)
            {
                student.Id++;
            }

            //Adds new student to the database then clears the input field.
            if (ModelState.IsValid)
            {
                using (Kismet_InfoEntities db = new Kismet_InfoEntities())
                {
                    db.Students.Add(student);
                    db.SaveChanges();
                }

                ModelState.Clear();
                ViewBag.Message = student.FirstName + " " + student.LastName + " successfully registered.";
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }