Exemple #1
0
 public TransactionService(DataContext dataContext, TransactionControlSettings transactionControlSettings, IMapper mapper, ITokenHelperService tokenHelperService, IInventoryService inventoryService)
 {
     _dataContext = dataContext;
     _transactionControlSettings = transactionControlSettings;
     _mapper             = mapper;
     _tokenHelperService = tokenHelperService;
     _inventoryService   = inventoryService;
 }
Exemple #2
0
        public void InstallServices(IServiceCollection services, IConfiguration configuration)
        {
            services.AddControllers();
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            var transactionControlSettings = new TransactionControlSettings();

            configuration.Bind(nameof(transactionControlSettings), transactionControlSettings);
            services.AddSingleton(transactionControlSettings);

            services.AddAutoMapper(typeof(Startup));

            services.AddSwaggerGen(x =>
            {
                x.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "CCG Rebates API", Version = "v1"
                });

                var security = new Dictionary <string, IEnumerable <string> >
                {
                    { "Bearer", new string[0] }
                };

                //var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                //var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                //x.IncludeXmlComments(xmlPath);

                x.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {
                    Description = "JWT Authorization header using the bearer scheme",
                    Name        = "Authorization",
                    In          = ParameterLocation.Header,
                    Type        = SecuritySchemeType.ApiKey
                });

                x.AddSecurityRequirement(new OpenApiSecurityRequirement()
                {
                    {
                        new OpenApiSecurityScheme
                        {
                            Reference = new OpenApiReference
                            {
                                Type = ReferenceType.SecurityScheme,
                                Id   = "Bearer"
                            },
                            Name = "Bearer",
                            In   = ParameterLocation.Header,
                        },
                        new List <string>()
                    }
                });
            });
        }