public BaseController(IMediator mediator, NoticeBoardContext databaseContext, IConfiguration configuration, IMapper mapper) { _configuration = configuration; _mediator = mediator; _databaseContext = databaseContext; _mapper = mapper; }
// 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); }
// 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); }
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; }
public GetBackgroundsQueryHandler(NoticeBoardContext _context) { context = _context; }
public GetSubRaceQueryHandler(NoticeBoardContext _context) { context = _context; }
public GetPlayerCharacterQueryHandler(NoticeBoardContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public GetAlignmentsQueryHandler(NoticeBoardContext _context) { context = _context; }
public GetLanguageQueryHandler(NoticeBoardContext _context) { context = _context; }
public GetSpellQueryHandler(NoticeBoardContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public GetClassOptionsQueryHandler(NoticeBoardContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public GetPCLevelQueryHandler(NoticeBoardContext context) { _context = context; }
public CreatePCCommandHandler(NoticeBoardContext context, ISessionInformation sessionInformation) { _context = context; _sessionInformation = sessionInformation; }
public SetPCArchetypeCommandHandler(NoticeBoardContext context) { _context = context; }
public LevelUpPCCommandHandler(NoticeBoardContext context) { _context = context; }
public SetPCAbilityScoresCommandHandler(NoticeBoardContext context) { _context = context; }
public GetPcFeatureQueryHandler(NoticeBoardContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public GetClassesQueryHandler(NoticeBoardContext _context) { context = _context; }
public GetPcEquipmentQueryHandler(NoticeBoardContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public GetSourcesQueryHandler(NoticeBoardContext context, ISessionInformation sessionInformation, IMapper mapper) { _context = context; _mapper = mapper; }
public SetPCAlignmentCommandHandler(NoticeBoardContext context) { _context = context; }
public GetArchetypeQueryHandler(NoticeBoardContext _context) { context = _context; }
public SetPCSkillsCommandHandler(NoticeBoardContext context) { _context = context; }
public SetPCRaceCommandHandler(NoticeBoardContext context) { _context = context; }
public GetCampaignQueryHandler(NoticeBoardContext context, ISessionInformation sessionInformation, IMapper mapper) { _context = context; _sessionInformation = sessionInformation; _mapper = mapper; }
public PlayerCharacterController(IMediator mediator, NoticeBoardContext databaseContext, IConfiguration configuration, IMapper mapper) : base(mediator, databaseContext, configuration, mapper) { }
public SetPCLanguagesCommandHandler(NoticeBoardContext context) { _context = context; }
public SetPCSpellSlotsCommandHandler(NoticeBoardContext context) { _context = context; }
public GetCharacterGenerationOptionsQueryHandler(NoticeBoardContext context, ISessionInformation sessionInformation, IMapper mapper) { _context = context; _mapper = mapper; }
public CampaignController(IMediator mediator, NoticeBoardContext databaseContext, IConfiguration configuration, IMapper mapper, ISessionInformation sessionInformation, IDataProtectionProvider dataProtectionProvider) : base(mediator, databaseContext, configuration, mapper, sessionInformation, dataProtectionProvider) { }