コード例 #1
0
 public UserService(ScalpayDbContext context, IMapper mapper, IMemoryCache cache, IHttpContextAccessor accessor)
 {
     _context  = context;
     _mapper   = mapper;
     _cache    = cache;
     _accessor = accessor;
 }
コード例 #2
0
        public void InitApplication(ScalpayDbContext context, IWebHostEnvironment env)
        {
            // json.net default settings
            JsonConvert.DefaultSettings = (() =>
            {
                var settings = new JsonSerializerSettings();
                settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                settings.NullValueHandling = NullValueHandling.Ignore;
                settings.Converters.Add(new StringEnumConverter());
                settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                settings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
                return(settings);
            });

            // init database
            context.Database.Migrate();

            // add default user
            if (!context.Users.Any())
            {
                context.Users.Add(new User()
                {
                    Username = "******",
                    Email    = "*****@*****.**",
                    FullName = "Admin",
                    Password = "******",
                    Role     = Role.Admin
                });
                context.SaveChanges();
            }

            // add scalpay project
            if (!context.Projects.Any())
            {
                context.Projects.Add(new Project()
                {
                    ProjectKey  = "__scalpay",
                    Description = "The Scalpay's configurations."
                });
                context.SaveChanges();
            }
        }
コード例 #3
0
ファイル: ProjectService.cs プロジェクト: KarlGong/Scalpay
 public ProjectService(ScalpayDbContext context, IMapper mapper, IMemoryCache cache)
 {
     _context = context;
     _mapper  = mapper;
     _cache   = cache;
 }
コード例 #4
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, ScalpayDbContext dbContext, ILogger logger)
        {
            InitApplication(dbContext, env);

            loggerFactory.AddSerilog(logger);

            app.UseScalpayException();

            app.UseRouting();

            app.UseScalpayAuthentication();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
コード例 #5
0
 public ProjectPermissionService(ScalpayDbContext context, IMemoryCache cache, IMapper mapper)
 {
     _context = context;
     _cache   = cache;
     _mapper  = mapper;
 }
コード例 #6
0
ファイル: ItemService.cs プロジェクト: KarlGong/Scalpay
 public ItemService(ScalpayDbContext context, IMemoryCache cache, IMapper mapper)
 {
     _context = context;
     _cache   = cache;
     _mapper  = mapper;
 }