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 AddCourse(Course entity)
 {
     using (var ctx = new StudentTrackerDbContext())
     {
         if (ctx.Courses.Any(x => x.CourseName.Equals(entity.CourseName, StringComparison.OrdinalIgnoreCase)))
         {
             return false;
         }
         ctx.Courses.Add(new Course { CourseName = entity.CourseName, MaxNumberOfStudents = entity.MaxNumberOfStudents });
         ctx.SaveChanges();
         var course = ctx.Courses.OrderByDescending(x => x.Id).First();
         entity.Id = course != null ? course.Id : 0;
         return true;
     }
 }