public List <StudentDetailsObject> GetStudentDetailsForSpecificStudent(StudentDetailsObject studentDetailsObject) { var details = context.StudentDetails.Where(w => w.Id == studentDetailsObject.Id).Select(s => new StudentDetailsObject { Id = s.Id, FirstName = s.FirstName, Surname = s.Surname, Course = s.Course, DoB = s.DoB, Married = s.Married, FullName = s.FullName }).ToList(); return(details); }
public void UpdateExistingStudent(StudentDetailsObject student) { var existingStudent = context.StudentDetails.Where(w => w.Id == student.Id).SingleOrDefault(); existingStudent.FirstName = student.FirstName; existingStudent.Surname = student.Surname; existingStudent.DoB = student.DoB; existingStudent.Course = student.Course; existingStudent.Married = student.Married; existingStudent.FullName = student.FullName; // context.StudentDetails.(newStudent); try { context.SaveChanges(); } catch (Exception e) { throw new Exception(); } }
public void WriteNewStudent(StudentDetailsObject student) { var newStudent = new StudentDetails { FirstName = student.FirstName, Surname = student.Surname, DoB = student.DoB, Course = student.Course, Married = student.Married, FullName = student.FullName }; context.StudentDetails.Add(newStudent); try { context.SaveChanges(); }catch (Exception e) { throw new Exception(); } }