Пример #1
0
 public ActionResult Edit([Bind(Include = "Id,Description,MajorId")] Class @class)
 {
     if (ModelState.IsValid)
     {
         db.Entry(@class).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(@class));
 }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,MajorId,Sat")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
 public ActionResult Edit([Bind(Include = "Id,Kickoff,Url")] Fixture fixture)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fixture).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fixture));
 }
Пример #4
0
 public ActionResult Edit([Bind(Include = "Id,Name")] School school)
 {
     if (ModelState.IsValid)
     {
         db.Entry(school).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(school));
 }
Пример #5
0
 public ActionResult Edit([Bind(Include = "Id,StudentId,ClassId,Grade")] Enrolled enrolled)
 {
     if (ModelState.IsValid)
     {
         db.Entry(enrolled).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(enrolled));
 }
Пример #6
0
 public RegisteredStudent Delete(DeletedStudent deletedStudent)
 {
     using (SchoolDataContext schoolContext = new SchoolDataContext())
     {
         Student studentToDelete = (Student)schoolContext.Students.Where(b => b.Id == deletedStudent.Id).First();
         schoolContext.Entry(studentToDelete).State = System.Data.Entity.EntityState.Deleted;
         schoolContext.SaveChanges();
         return(studentToDelete.toDTO());
     }
 }
Пример #7
0
 public ActionResult Edit([Bind(Include = "Id,Description,MinSat")] Major major)
 {
     if (ModelState.IsValid)
     {
         db.Entry(major).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(major));
 }
Пример #8
0
 public RegisteredStudent Update(UpdateStudent updateRegistry)
 {
     using (SchoolDataContext schoolContext = new SchoolDataContext())
     {
         var studentToUpdate = updateRegistry.ToEntity();
         schoolContext.Students.Attach(studentToUpdate);
         //schoolContext.Entry(studentToUpdate).Property(x => x.Name).IsModified = true;
         schoolContext.Entry(studentToUpdate).State = System.Data.Entity.EntityState.Modified;
         schoolContext.SaveChanges();
         return(studentToUpdate.toDTO());
     }
 }