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