Пример #1
0
 public virtual void AddStudent(string firstName, string lastName)
 {
     StudentData student = new StudentData {
         FirstName = firstName,
         LastName = lastName,
         DateCreated = DateTime.Now.Date
     };
     studentService.AddStudent(student);
 }
 public void AddStudent(StudentData studentData)
 {
     using (KaplanTestPrepEntities con = new KaplanTestPrepEntities()) {
         var student = new Student {
             FirstName = studentData.FirstName,
             LastName = studentData.LastName,
             DateCreated = studentData.DateCreated
         };
         con.Students.Add(student);
         con.SaveChanges();
     }
 }
        public bool UpdateStudent(StudentData studentData)
        {
            using (KaplanTestPrepEntities con = new KaplanTestPrepEntities()) {
                var student = con.Students.Where(x => x.StudentId == studentData.StudentId).FirstOrDefault();
                if (student != null) {
                    student.FirstName = studentData.FirstName;
                    student.LastName = studentData.LastName;
                    student.DateCreated = studentData.DateCreated;

                    con.SaveChanges();
                    return true;
                }
            }
            return false;
        }