public ActionResult Edit([Bind(Include = "HeadquartersId,Name,Address,Phone")] Headquarter headquarter)
 {
     if (ModelState.IsValid)
     {
         db.Entry(headquarter).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(headquarter));
 }
 public ActionResult Edit([Bind(Include = "Id,DeptCode,DeptName")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(department));
 }
Exemple #3
0
 public ActionResult Edit([Bind(Include = "TeacherId,Name,LastName")] Teacher teacher)
 {
     if (ModelState.IsValid)
     {
         db.Entry(teacher).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(teacher));
 }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "SubjectID,TeacherId,Name,Schedule")] Subject subject)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subject).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TeacherId = new SelectList(db.Teachers, "TeacherId", "Name", subject.TeacherId);
     return(View(subject));
 }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "Id,Name,Email,RegNo,DepartmentId")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentId = new SelectList(db.Departments, "Id", "DeptCode", student.DepartmentId);
     return(View(student));
 }
 public ActionResult Edit([Bind(Include = "StudentID,Name,LastName,HeadquartersId")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.HeadquartersId = new SelectList(db.Headquarters, "HeadquartersId", "Name", student.HeadquartersId);
     return(View(student));
 }
        public ActionResult Edit([Bind(Include = "StudentId,FirstName,LastName,EnrollmentDate")] Student student)
        {
            if (!ModelState.IsValid)
            {
                return(View(student));
            }

            _universityDb.Entry(student).State = EntityState.Modified;
            _universityDb.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemple #8
0
        private static void UpdateExample3()
        {
            var studentFromGui = new Student()
            {
                FirstName = "User changed first name again",
                LastName  = "User changed last name again",
                Id        = 1
            };

            using (var db = new UniversityDb(ConnectionString))
            {
                // Mark entry as modified. Context will start tracking it.
                db.Entry(studentFromGui).State = EntityState.Modified;
                // Let EF update everything...
                db.SaveChanges();
            }
        }