Beispiel #1
0
 /// <summary>
 /// Create a new user controller.
 /// </summary>
 public UserController(
     UserFinderByUsername userFinder,
     UserRegistrar userRegistrar
     )
 {
     this.userFinder    = userFinder;
     this.userRegistrar = userRegistrar;
 }
        public async Task <IActionResult> Registration(
            CancellationToken cancellationToken,
            [FromBody] RegistrationBinding binding,
            [FromServices] IUserRepository repository,
            [FromServices] UserRegistrar registrar)
        {
            try{
                var user = await registrar.Registrate(binding.Login, binding.Name, binding.Password, cancellationToken);

                await repository.Save(user, cancellationToken);

                return(NoContent());
            }
            catch (UserAlreadyExistsException) {
                throw new ApiException(HttpStatusCode.Conflict, ErrorCodes.UserAlreadyExists, "User already exists");
            }
        }
Beispiel #3
0
        public static void Start()
        {
            var builder = new ContainerBuilder();

            // Auto-Wire
            builder.AutowireDependencies(assemblyNames: new[] { LibraryDll, WebsiteDll });

            builder.RegisterGlassServices();
            builder.RegisterCacheServices();
            builder.RegisterProcessors(new[] { WebsiteDll, LibraryDll });
            builder.RegisterGlassMvcServices(WebsiteDll, LibraryDll);
            builder.RegisterGlassFactory(LibraryDll, VelirSearchDll, ModelsDll);
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly()).WithAttributeFilter();
            builder.RegisterControllers(Assembly.GetExecutingAssembly()).WithAttributeFilter();
            builder.RegisterType <CustomSitecoreHelper>().AsSelf();
            builder.RegisterType <ArticleUtil>().AsSelf();
            builder.RegisterType <SitecoreSaverUtil>().AsSelf();
            builder.RegisterType <EmailUtil>().AsSelf();

            //Velir Search Library
            builder.RegisterModule <SearchModule>();
            builder.RegisterModule <SolrSearchModule>();
            SearchRegistrar.RegisterDependencies(builder);

            SessionRegistrar.RegisterDependencies(builder);
            AuthenticationRegistrar.RegisterDependencies(builder);
            SalesforceRegistrar.RegisterDependencies(builder);
            UserRegistrar.RegisterDependencies(builder);
            RegistrationRegistrar.RegisterDependencies(builder);
            CompanyRegistrar.RegisterDependencies(builder);
            NlmRegistrar.RegisterDependencies(builder);
            ScheduledPublishingRegistrar.RegisterDependencies(builder);
            SiteDebuggingRegistrar.RegisterDependencies(builder);
            LoggingRegistrar.RegisterDependencies(builder);
            EntitlementsRegistrar.RegisterDependencies(builder);
            PurchaseRegistrar.RegisterDependencies(builder);
            DCDRegistrar.RegisterDependencies(builder);

            // Custom Modules
            builder.RegisterModule(new LogInjectionModule <ILog>(LogManager.GetLogger));
            builder.RegisterModule(new AutomapperModule(LibraryDll));

#if DEBUG
            builder.RegisterModule(new MiniProfilerModule(WebsiteDll, LibraryDll, VelirSearchDll, GlassMapperDll, GlassMapperScDll, GlassMapperMvcDll));
#endif

            // Custom Registrations
            CustomMvcRegistrar.RegisterDependencies(builder, WebsiteDll);
            GlassMapperRegistrar.RegisterDependencies(builder);
            builder.RegisterType <Library.Caching.CrossSiteCacheProvider>().As <Library.Caching.ICrossSiteCacheProvider>().SingleInstance();

            // This is necessary to 'seal' the container, and make it resolvable from the AutofacStartup.ServiceLocator singleton
            IContainer container = builder.Build();
            container.RegisterContainer();

            // Create the dependency resolver.
            var resolver = new AutofacWebApiDependencyResolver(container);

            // Configure Web API with the dependency resolver.
            GlobalConfiguration.Configuration.DependencyResolver = resolver;

            // Configure MVC with dependency resolver
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }