public void Initialize()
        {
            stService = new StudentTrackerService.StudentTrackerService();
            peter = new Student { FirstName = "PeterTest", LastName = "SimonsTest", Sex = Sex.Male, Age = 25 };
            sarah = new Student { FirstName = "SarahTest", LastName = "ClarksTest", Sex = Sex.Female, Age = 20 };
            jessy = new Student { FirstName = "JessyTest", LastName = "AlgienTest", Sex = Sex.Female, Age = 22 };

            math = new Course { CourseName = "MathematicsTest", MaxNumberOfStudents = 15 };
            calculus = new Course { CourseName = "CalculusTest", MaxNumberOfStudents = 10 };
            discrete = new Course { CourseName = "DiscreteTest", MaxNumberOfStudents = 2 };

            using (var ctx = new StudentTrackerDbContext())
            {
                ctx.Students.Add(peter);
                ctx.Students.Add(sarah);
                ctx.Students.Add(jessy);
                ctx.SaveChanges();

                math.Students.Add(peter);
                math.Students.Add(jessy);

                ctx.Courses.Add(math);
                ctx.Courses.Add(calculus);
                ctx.Courses.Add(discrete);

                ctx.SaveChanges();
            }
        }
        public void Initialize()
        {
            stService = new StudentTrackerService.StudentTrackerService();
            peter = new Student { FirstName = "PeterTest", LastName = "SimonsTest", Sex = Sex.Male, Age = 25 };
            sarah = new Student { FirstName = "SarahTest", LastName = "ClarksTest", Sex = Sex.Female, Age = 20 };
            jessy = new Student { FirstName = "JessyTest", LastName = "AlgienTest", Sex = Sex.Female, Age = 22 };

            math = new Course { CourseName = "MathematicsTest", MaxNumberOfStudents = 15 };
            calculus = new Course { CourseName = "CalculusTest", MaxNumberOfStudents = 10 };
            discrete = new Course { CourseName = "DiscreteTest", MaxNumberOfStudents = 2 };

            using (var ctx = new StudentTrackerDbContext())
            {
                ctx.Students.Add(peter);
                ctx.Students.Add(sarah);
                ctx.Students.Add(jessy);
                ctx.SaveChanges();

                discrete.Students.Add(sarah);
                calculus.Students.Add(sarah);

                ctx.Courses.Add(math);
                ctx.Courses.Add(calculus);
                ctx.Courses.Add(discrete);

                ctx.SaveChanges();

                expectedCourses = new List<StudentCourse>();
                foreach (var course in ctx.Courses)
                {
                    expectedCourses.Add(new StudentCourse { CourseName = course.CourseName, AssignedStudents = course.Students.Count, Id = course.Id, IsActive = course.Students.Count < course.MaxNumberOfStudents, MaxStudents = course.MaxNumberOfStudents, IsAppliedFor = course.Students.Any(x => x.Id == sarah.Id) });
                }
            }
        }
 public bool AddStudent(Student entry)
 {
     using (var ctx = new StudentTrackerDbContext())
     {
         if (IsDublicateName(entry.FirstName, entry.LastName, ctx.Students))
         {
             return false;
         }
         ctx.Students.Add(entry);
         ctx.SaveChanges();
         var student = ctx.Students.OrderByDescending(x => x.Id).First();
         entry.Id = student != null ? student.Id : 0;
         return true;
     }
 }