// Update student public Student UpdateStudent(Student model) { Student student = DB.Students.Where(s => s.Id == model.Id).SingleOrDefault(); if (student != null) { DB.Entry(student).CurrentValues.SetValues(model); DB.SaveChanges(); return(model); } return(null); }
// Update subject public Subject UpdateSubject(Subject model) { Subject subject = DB.Subjects.Where(s => s.Id == model.Id).SingleOrDefault(); if (subject != null) { DB.Entry(subject).CurrentValues.SetValues(model); DB.SaveChanges(); return(model); } return(null); }