예제 #1
0
 public BaseController(IMediator mediator, NoticeBoardContext databaseContext, IConfiguration configuration, IMapper mapper)
 {
     _configuration   = configuration;
     _mediator        = mediator;
     _databaseContext = databaseContext;
     _mapper          = mapper;
 }
예제 #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });


            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddTransient <IMediator, Mediator>();
            new Utility.DIMappers.MainMapper().Setup(services);

            // DB Setup
            services.AddTransient <NoticeBoardContext>(serviceProvider =>
            {
                DbContextOptionsBuilder <NoticeBoardContext> options = new DbContextOptionsBuilder <NoticeBoardContext>();
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));

                var context = new NoticeBoardContext(options.Options);

                return(context);
            });

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MapperProfiles());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);
        }
예제 #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDataProtection();

            services.AddControllersWithViews().AddRazorRuntimeCompilation().AddNewtonsoftJson();

            services.AddTransient <IMediator, Mediator>();
            new MainMapper().Setup(services);

            // DB Setup
            services.AddTransient <NoticeBoardContext>(serviceProvider =>
            {
                DbContextOptionsBuilder <NoticeBoardContext> options = new DbContextOptionsBuilder <NoticeBoardContext>();
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));

                var context = new NoticeBoardContext(options.Options);

                return(context);
            });

            services.AddScoped <ISessionInformation>(serviceProvider =>
            {
                DbContextOptionsBuilder <NoticeBoardContext> options = new DbContextOptionsBuilder <NoticeBoardContext>();
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));

                var context = new NoticeBoardContext(options.Options);

                SessionInformation sessionInformation = new SessionInformation();

                var contextAccessor = serviceProvider.GetService <IHttpContextAccessor>();
                if (true) //contextAccessor.HttpContext != null) //TODO: Get HttpContext
                {
                    var claims = contextAccessor?.HttpContext?.User?.Claims;

                    var userid = "1"; //TODO: Replace with Id from user claim
                    //var userid = Convert.ToInt32(claims?.FirstOrDefault(n => n.Type == "objectid")?.Value);

                    var user = context.Player.SingleOrDefault(n => n.UserId == userid && n.IsEnabled);

                    if (user != null)
                    {
                        sessionInformation.Name      = user.Name;
                        sessionInformation.UserId    = userid;
                        sessionInformation.IsDM      = user.IsDm;
                        sessionInformation.IsEnabled = user.IsEnabled;
                    }
                }
                return(sessionInformation);
            });

            var mappingConfig = new MapperConfiguration(mc =>
            {
                mc.AddProfile(new MapperProfiles());
            });

            IMapper mapper = mappingConfig.CreateMapper();

            services.AddSingleton(mapper);
        }
예제 #4
0
 public BaseController(IMediator mediator, NoticeBoardContext databaseContext, IConfiguration configuration, IMapper mapper, ISessionInformation sessionInformation, IDataProtectionProvider dataProtectionProvider)
 {
     _configuration          = configuration;
     _mediator               = mediator;
     _context                = databaseContext;
     _mapper                 = mapper;
     _sessionInformation     = sessionInformation;
     _dataProtectionProvider = dataProtectionProvider;
 }
예제 #5
0
 public GetBackgroundsQueryHandler(NoticeBoardContext _context)
 {
     context = _context;
 }
예제 #6
0
 public GetSubRaceQueryHandler(NoticeBoardContext _context)
 {
     context = _context;
 }
예제 #7
0
 public GetPlayerCharacterQueryHandler(NoticeBoardContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #8
0
 public GetAlignmentsQueryHandler(NoticeBoardContext _context)
 {
     context = _context;
 }
예제 #9
0
 public GetLanguageQueryHandler(NoticeBoardContext _context)
 {
     context = _context;
 }
예제 #10
0
 public GetSpellQueryHandler(NoticeBoardContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #11
0
 public GetClassOptionsQueryHandler(NoticeBoardContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #12
0
 public GetPCLevelQueryHandler(NoticeBoardContext context)
 {
     _context = context;
 }
예제 #13
0
 public CreatePCCommandHandler(NoticeBoardContext context, ISessionInformation sessionInformation)
 {
     _context            = context;
     _sessionInformation = sessionInformation;
 }
예제 #14
0
 public SetPCArchetypeCommandHandler(NoticeBoardContext context)
 {
     _context = context;
 }
예제 #15
0
 public LevelUpPCCommandHandler(NoticeBoardContext context)
 {
     _context = context;
 }
 public SetPCAbilityScoresCommandHandler(NoticeBoardContext context)
 {
     _context = context;
 }
예제 #17
0
 public GetPcFeatureQueryHandler(NoticeBoardContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #18
0
 public GetClassesQueryHandler(NoticeBoardContext _context)
 {
     context = _context;
 }
예제 #19
0
 public GetPcEquipmentQueryHandler(NoticeBoardContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #20
0
 public GetSourcesQueryHandler(NoticeBoardContext context, ISessionInformation sessionInformation, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #21
0
 public SetPCAlignmentCommandHandler(NoticeBoardContext context)
 {
     _context = context;
 }
예제 #22
0
 public GetArchetypeQueryHandler(NoticeBoardContext _context)
 {
     context = _context;
 }
예제 #23
0
 public SetPCSkillsCommandHandler(NoticeBoardContext context)
 {
     _context = context;
 }
예제 #24
0
 public SetPCRaceCommandHandler(NoticeBoardContext context)
 {
     _context = context;
 }
예제 #25
0
 public GetCampaignQueryHandler(NoticeBoardContext context, ISessionInformation sessionInformation, IMapper mapper)
 {
     _context            = context;
     _sessionInformation = sessionInformation;
     _mapper             = mapper;
 }
예제 #26
0
 public PlayerCharacterController(IMediator mediator, NoticeBoardContext databaseContext, IConfiguration configuration, IMapper mapper) : base(mediator, databaseContext, configuration, mapper)
 {
 }
예제 #27
0
 public SetPCLanguagesCommandHandler(NoticeBoardContext context)
 {
     _context = context;
 }
예제 #28
0
 public SetPCSpellSlotsCommandHandler(NoticeBoardContext context)
 {
     _context = context;
 }
 public GetCharacterGenerationOptionsQueryHandler(NoticeBoardContext context, ISessionInformation sessionInformation, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
예제 #30
0
 public CampaignController(IMediator mediator, NoticeBoardContext databaseContext, IConfiguration configuration, IMapper mapper, ISessionInformation sessionInformation, IDataProtectionProvider dataProtectionProvider) :
     base(mediator, databaseContext, configuration, mapper, sessionInformation, dataProtectionProvider)
 {
 }