public void UpdateStudent(Student student) { /* int result = 0; using (db5ba730478f594a8c890aa55700666a55Entities context = new db5ba730478f594a8c890aa55700666a55Entities()) { Student s = GetOneStudent(student.StudentID); if (s != null) { s.Lastname = student.Lastname; s.Firstname = student.Firstname; s.MI = student.MI; context.Students.Add(student); context.SaveChanges(); } }*/ //return result > 0; using (var ctx = new db5ba730478f594a8c890aa55700666a55Entities()) { var stud = (from s in ctx.Students where s.StudentID == student.StudentID select s).FirstOrDefault(); stud.Lastname = student.Lastname; stud.Firstname = student.Firstname; stud.MI = student.MI; int num = ctx.SaveChanges(); } }
public void CreateStudent(Student student) { int result = 0; using (db5ba730478f594a8c890aa55700666a55Entities context = new db5ba730478f594a8c890aa55700666a55Entities()) { context.Students.Add(student); result = context.SaveChanges(); } //return result > 0; }