Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddMvc();
            services.AddOptions();
            services.Configure <StripeOptions>(Configuration.GetSection("Stripe"));

            services.Configure <UserGroupOptions>(Configuration.GetSection("UserGroups"));

            var groups = new UserGroupOptions();

            for (int i = 0; i < 20; i++)
            {
                var name = Configuration.GetValue <string>($"UserGroups:{i}:GroupName");
                var code = Configuration.GetValue <string>($"UserGroups:{i}:GroupCode");
                if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(code))
                {
                    groups.UserGroups.Add(new UserGroup {
                        GroupName = name, GroupCode = code
                    });
                }
            }

            services.AddSingleton <UserGroupOptions>(groups);
        }
Exemplo n.º 2
0
 public UGRegistrationController(IOptions <StripeOptions> stripeOptions, UserGroupOptions ugOptions)
 {
     _stripeOptions = stripeOptions.Value;
     _ugOptions     = ugOptions;
 }