Asp.net C # DDD - Implementing Api Web

1

I am developing a System, with DDD structure with Simple Injector.

When developing the WEB API, the data returned from the DB is null.

In other tests performed in the MVC view, the same data is returned normally. The problem is in the implementation of dependency injection, but I can not identify where.

Simple Injector implementation

    [assembly: WebActivator.PostApplicationStartMethod(typeof(App_Start.SimpleInjectorWebApiInitializer), "Initialize")]

namespace Api.App_Start
{
    using System.Web.Http;
    using SimpleInjector;
    using SimpleInjector.Integration.WebApi;
    using SimpleInjector.Lifestyles;          

    public static class SimpleInjectorWebApiInitializer
    {
        /// <summary>Initialize the container and register it as Web API Dependency Resolver.</summary>
        public static void Initialize()
        {
            var container = new Container();
            container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();

            InitializeContainer(container);
            container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
            container.Verify();

            GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
        }

        private static void InitializeContainer(Container container)
        {
            IoC.Bindings.Start(container);
        }
    }
}

IoC

namespace IoC
{
    public class Bindings
    {
        public static void Start(Container container)
        {
            //Infrastrutura
            container.Register<IRepositoryManager, RepositoryManager>();
            container.Register<IWorkUnit, WorkUnit>();
            //container.Register(typeof(IBaseRepositories<>), typeof(BaseRepositories<>), Lifestyle.Scoped);
            container.Register(typeof(IUsuarioRepositories), typeof(UsuarioRepositories), Lifestyle.Scoped);
            container.Register(typeof(ISistemaRepositories), typeof(SistemaRepositories), Lifestyle.Scoped);

            //Dominio
            container.Register(typeof(IUsuarioDomain), typeof(UsuarioDomain), Lifestyle.Scoped);
            container.Register(typeof(ISistemaDomain), typeof(SistemaDomain), Lifestyle.Scoped);

            //Service Locator
            ServiceLocator.SetLocatorProvider(() => new SimpleInjectorServiceLocatorAdapter(container));
        }
    }
}
    
asked by anonymous 03.09.2017 / 22:56

0 answers