예제 #1
0
        public async static Task <TeamController> getTeamsController()
        {
            IServiceProvider _serviceProvider = ServiceBuilder.getServiceProvider();
            var context           = _serviceProvider.GetRequiredService <ApplicationDbContext>();
            var userManager       = _serviceProvider.GetRequiredService <UserManager <ApplicationUser> >();
            var signInManager     = _serviceProvider.GetRequiredService <SignInManager <ApplicationUser> >();
            var userManagerResult = await userManager.CreateAsync(
                new ApplicationUser { Id = Constants.USER_ID, UserName = Constants.DEFAULT_EMAIL, Email = Constants.DEFAULT_EMAIL },
                Constants.DEFAULT_PASSWORD);

            await signInManager.PasswordSignInAsync(Constants.DEFAULT_EMAIL, Constants.DEFAULT_PASSWORD, false, lockoutOnFailure : false);

            var httpContextAccessor = _serviceProvider.GetRequiredService <IHttpContextAccessor>();
            var controller          = new TeamController(context, httpContextAccessor, null);

            SetRouteData(_serviceProvider, httpContextAccessor, controller);
            return(controller);
        }
예제 #2
0
        public static AccountController getAccountController()
        {
            IServiceProvider _serviceProvider = ServiceBuilder.getServiceProvider();
            var userManager   = _serviceProvider.GetRequiredService <UserManager <ApplicationUser> >();
            var signInManager = _serviceProvider.GetRequiredService <SignInManager <ApplicationUser> >();

            var httpContext = _serviceProvider.GetRequiredService <IHttpContextAccessor>().HttpContext;
            var emailSender = _serviceProvider.GetRequiredService <IEmailSender>();
            var context     = _serviceProvider.GetRequiredService <ApplicationDbContext>();
            var userService = _serviceProvider.GetRequiredService <IUserService>();

            var controller = new AccountController(userManager, signInManager, emailSender, context, userService);

            controller.ControllerContext.HttpContext = httpContext;
            var httpContextAccessor = _serviceProvider.GetRequiredService <IHttpContextAccessor>();

            SetRouteData(_serviceProvider, httpContextAccessor, controller);
            return(controller);
        }