Beispiel #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });
            services.AddHttpContextAccessor();
            services.AddDbContext <ApplicationContext>();

            services.AddScoped <CustomerService>();
            services.AddScoped <GroupClassService>();
            services.AddScoped <InstructorService>();
            services.AddScoped <PaymentService>();
            services.AddScoped <PhysicalEvaluationService>();
            services.AddScoped <PresenceService>();
            services.AddScoped <UserService>();
            services.AddScoped <VacationService>();
            services.AddScoped <MockService>();

            services.AddScoped <CustomerDataAccess>();
            services.AddScoped <GroupClassDataAccess>();
            services.AddScoped <InstructorDataAccess>();
            services.AddScoped <PaymentDataAccess>();
            services.AddScoped <PhysicalEvaluationDataAccess>();
            services.AddScoped <PresenceDataAccess>();
            services.AddScoped <UserDataAccess>();
            services.AddScoped <VacationDataAccess>();



            AuthorizationProvider.Configure(services);
            ApplicationEnv.ServiceProvider = services.BuildServiceProvider();

            if (ApplicationEnv.GetBoolConfiguration(Constants.RUN_MIGRATIONS) &&
                !ApplicationEnv.GetBoolConfiguration(Constants.USE_MEMORY_DB))
            {
                ((ApplicationContext)Activator.CreateInstance(typeof(ApplicationContext))).Database.Migrate();
            }

            MockService mockService = ApplicationEnv.ServiceProvider.GetService <MockService>();

            mockService.AdminUser();

            if (ApplicationEnv.GetBoolConfiguration(Constants.RUN_START_TASK))
            {
                mockService.Mock();
            }
        }