Exemple #1
0
        public object GetService(Type serviceType)
        {
            if (serviceType == typeof(StudentsController))
            {
                var context    = new StudentsDbEntities();
                var repository = new DbStudentRepository(context);

                return(new StudentsController(repository));
            }
            else if (serviceType == typeof(SchoolsController))
            {
                var context    = new StudentsDbEntities();
                var repository = new DbSchoolRepository(context);

                return(new SchoolsController(repository));
            }
            else if (serviceType == typeof(MarksController))
            {
                var context    = new StudentsDbEntities();
                var repository = new DbMarkRepository(context);

                return(new MarksController(repository));
            }
            else
            {
                return(null);
            }
        }
        public InMemoryHttpServer(string baseUrl, DbStudentRepository repository)
        {
            this.baseUrl = baseUrl;
            var config = new HttpConfiguration();

            this.AddHttpRoutes(config.Routes);
            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

            var resolver = new TestPlacesDependencyResolver <T>();

            resolver.StudentsRepository = repository;
            config.DependencyResolver   = resolver;

            var server = new HttpServer(config);

            this.client = new HttpClient(server);
        }
        public object GetService(Type serviceType)
        {
            if (serviceType == typeof(UniversityController))
            {
                var context = new SchoolContext();
                var repository = new DbSchoolRepository(context);

                return new UniversityController(repository);
            }
            else if (serviceType == typeof(StudentController))
            {
                var context = new SchoolContext();
                var repository = new DbStudentRepository(context);

                return new StudentController(repository);
            }
            else
            {
                return null;
            }
        }
 public StudentsController(IRepository<Student> studentsRepository)
 {
     this.studentsRepository = (DbStudentRepository)studentsRepository;
 }
 public StudentsController(IRepository <Student> studentsRepository)
 {
     this.studentsRepository = (DbStudentRepository)studentsRepository;
 }
 public StudentsController(DbStudentRepository studentsRepository)
 {
     this.studentsRepository = studentsRepository;
 }
 public StudentsController(DbStudentRepository studentsRepository)
 {
     this.studentsRepository = studentsRepository;
 }