public static string GetWebApiUrl(this IWebHostEnvironment environment, IConfiguration configuration, bool test = false)
        {
            ConnectionType conType            = environment.GetConnectionType(test);
            string         connectionTypeName = Enum.GetName(typeof(ConnectionType), conType);
            string         result             = configuration.GetSection($"WebApi:{connectionTypeName}").Get <string>();

            return(result);
        }
Ejemplo n.º 2
0
        public static void AddDependencies(this IServiceCollection services, IConfiguration configuration, IWebHostEnvironment environment)
        {
            string connectionString = configuration.GetCustomConnectionString(environment.GetConnectionType());
            string migrationName    = "GeneralStockMarket.WebAPI";

            services.AddTransient <DbContext, GeneralStockMarketDbContext>();
            services.AddTransient <GeneralStockMarketDbContext>();

            services.AddDbContext <GeneralStockMarketDbContext>(opt =>
                                                                opt.UseSqlServer(connectionString, sqlOpt =>
                                                                                 sqlOpt.MigrationsAssembly(migrationName)
                                                                                 )
                                                                );

            services.AddHttpContextAccessor();

            services.AddTransient(typeof(IGenericService <>), typeof(GenericManager <>));
            services.AddTransient(typeof(IGenericRepository <>), typeof(EfGenericRepository <>));

            services.AddTransient <IProductService, ProductManager>();
            services.AddTransient <IProductRepository, EfProductRepository>();

            services.AddTransient <IWalletService, WalletManager>();
            services.AddTransient <IWalletRepository, EfWalletRepository>();

            services.AddTransient <IProductDepositRequestService, ProductDepositRequestManager>();
            services.AddTransient <IProductDepositRequestRepository, EfProductDepositRequestRepository>();

            services.AddTransient <IProductItemService, ProductItemManager>();
            services.AddTransient <IProductItemRepository, EfProductItemRepository>();

            services.AddTransient <ITradeService, TradeManager>();
            services.AddTransient <ITradeRepository, EfTradeRepository>();

            services.AddTransient <IRequestService, RequestManager>();

            services.AddTransient <ITransactionRepository, EfTransactionRepository>();
            services.AddTransient <ILimitOptionRequestRepository, EfLimitOptionRequestRepository>();


            services.AddScoped <ISharedIdentityService, SharedIdentityService>();

            services.AddAutoMapper(typeof(ProductMappingProfile));
            services.AddScoped <ICustomMapper, CustomMapper>();
        }