Esempio n. 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(
                options =>
            {
                options.ReturnHttpNotAcceptable = true;
            }
                ).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddCors();

            // Add in the http client factory
            services.AddHttpClient();
            services.AddScoped <ILottoDrawService, LottoDrawService>(
                (ctx) =>
            {
                var openRepo    = new OpenDrawsRepository();
                var currentRepo = new CurrentDrawRepository();
                return(new LottoDrawService(openRepo, currentRepo));
            });

            services.AddSwaggerGen(
                c => { c.SwaggerDoc("v1", new Info()
                {
                    Title = "Lottery Code Challenge", Version = "v1"
                }); });

            // In production, the Angular files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "client/dist";
            });
        }
Esempio n. 2
0
 public LottoDrawService(OpenDrawsRepository openDrawsRepository, CurrentDrawRepository currentDrawRepository)
 {
     _openDrawsRepository = openDrawsRepository ?? throw new ArgumentNullException(
                                      nameof(openDrawsRepository), "open draws repository cannot be null.");
     _currentDrawRepository = currentDrawRepository ?? throw new ArgumentNullException(
                                        nameof(currentDrawRepository), "current draw repository cannot be null.");
 }