Ejemplo n.º 1
0
        private void InitializeFactories()
        {
            EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory());

            var dto = new BlogDTO(); // this is only to force  current domain to load de .DTO assembly and all profiles

            var adapterfactory = new AutomapperTypeAdapterFactory();

            TypeAdapterFactory.SetCurrent(adapterfactory);

            //Localization
            LocalizationFactory.SetCurrent(new ResourcesManagerFactory());
        }
Ejemplo n.º 2
0
        public void ConfigureServices(IServiceCollection services)
        {
            // Configure EntityFramework to use an InMemory database.
            //services.AddDbContext<MyBlogContext>(options =>
            //        options.UseMySql(Configuration.GetConnectionString("MyBlogContext")));
            services.AddDbContext <UnitOfWork>(options =>
            {
                options.EnableSensitiveDataLogging();
                options.UseMySql(Configuration.GetConnectionString("MyBlogContext"));
            });


            services.AddControllersWithViews().AddRazorRuntimeCompilation();

            //services.AddControllersWithViews(options =>
            //{
            //    options.Filters.Add(new ValidateModelAttribute()); // an instance
            //    options.Filters.Add(typeof(LoggerAttribute));
            //}).AddRazorRuntimeCompilation();


            ////Custom Exception and validation Filter
            //services.AddScoped<CustomExceptionFilterAttribute>();


            //Repositories
            services.AddScoped <IBlogInfoRepository, BlogInfoRepository>();
            services.AddScoped <IBlogUserRepository, BlogUserRepository>();
            services.AddScoped <IBlogClassRepository, BlogClassRepository>();



            //DomainServices
            services.AddScoped <IBlogDomainService, BlogDomainService>();
            services.AddScoped <IUserDomainService, UserDomainService>();
            services.AddScoped <IClassDomainService, ClassDomainService>();

            //AppServices
            services.AddScoped <IBlogInfoAppService, BlogInfoAppService>();
            services.AddScoped <IBlogUserAppService, BlogUserAppService>();
            services.AddScoped <IBlogClassAppService, BlogClassAppService>();

            services.AddAutoMapper(typeof(CommonProfile));

            //Validator
            EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory());

            //Localization
            LocalizationFactory.SetCurrent(new ResourcesManagerFactory());
        }
Ejemplo 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.AddDbContext <MainBCUnitOfWork>();
            //Custom Exception and validation Filter
            services.AddScoped <CustomExceptionFilterAttribute>();

            //Repositories

            services.AddScoped <IBankAccountRepository, BankAccountRepository>();
            services.AddScoped <ICountryRepository, CountryRepository>();
            services.AddScoped <ICustomerRepository, CustomerRepository>();
            services.AddScoped <IOrderRepository, OrderRepository>();
            services.AddScoped <IProductRepository, ProductRepository>();

            // Domain Services
            services.AddScoped <IBankTransferService, BankTransferService>();

            services.AddScoped <ISalesAppService, SalesAppService>();
            services.AddScoped <ICustomerAppService, CustomerAppService>();
            services.AddScoped <IBankAppService, BankAppService>();

            //Adapters
            services.AddScoped <ITypeAdapterFactory, AutomapperTypeAdapterFactory>();
            TypeAdapterFactory.SetCurrent(services.BuildServiceProvider().GetService <ITypeAdapterFactory>());

            //Validator
            EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory());

            //Localization
            LocalizationFactory.SetCurrent(new ResourcesManagerFactory());


            // Add framework services.
            services.AddMvc(options =>
            {
                options.Filters.Add(new ValidateModelAttribute()); // an instance
                options.Filters.Add(typeof(LoggerAttribute));
            });
        }
Ejemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Configure EntityFramework to use an InMemory database.
            services.AddDbContext <BloggingContext>();

            // Add framework services.
            services.AddMvc(options =>
            {
                options.Filters.Add(new ValidateModelAttribute()); // an instance
                options.Filters.Add(typeof(LoggerAttribute));
            })
            .AddFluentValidation(fv => { });

            // can then manually register validators
            services.AddTransient <IValidator <BlogDTO>, BlogDTOValidator>();
            services.AddTransient <IValidator <PostDTO>, PostDTOValidator>();

            //Custom Exception and validation Filter
            services.AddScoped <CustomExceptionFilterAttribute>();

            //Repositories
            services.AddScoped <IImageRepository, ImageRepository>();
            services.AddScoped <IPostRepository, PostRepository>();
            services.AddScoped <IBlogRepository, BlogRepository>();

            //Services
            services.AddScoped <IPostsService, PostsService>();
            services.AddScoped <IBlogsService, BlogsService>();

            //Adapters
            services.AddScoped <ITypeAdapterFactory, AutomapperTypeAdapterFactory>();
            TypeAdapterFactory.SetCurrent(services.BuildServiceProvider().GetService <ITypeAdapterFactory>());

            //Validator
            EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory());

            //Localization
            LocalizationFactory.SetCurrent(new ResourcesManagerFactory());

            // Register the Swagger generator, defining one or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
                {
                    Version        = "v1",
                    Title          = "DDD N-Layered Architecture",
                    Description    = "DDD N-Layered Architecture with .Net Core 2 (NLayerAppV3)",
                    TermsOfService = "None",
                    Contact        = new Swashbuckle.AspNetCore.Swagger.Contact {
                        Name = "César Castro", Email = "*****@*****.**", Url = "https://www.linkedin.com/in/c%C3%A9sar-castro-91b56211/"
                    },
                    License = new Swashbuckle.AspNetCore.Swagger.License {
                        Name = "Use under my own License", Url = "https://www.microsoft.com/net/learn/architecture"
                    }
                });

                //Set the comments path for the swagger json and ui.
                var basePath = PlatformServices.Default.Application.ApplicationBasePath;
                var xmlPath  = Path.Combine(basePath, "NLayerApp.DistributedServices.BlogBoundedContext.xml");
                c.IncludeXmlComments(xmlPath);
            });
        }
Ejemplo n.º 5
0
 public BankAccountAggTests()
 {
     //Localization
     LocalizationFactory.SetCurrent(new ResourcesManagerFactory());
 }
Ejemplo n.º 6
0
 public OrderSpecificationsTests()
 {
     //Localization
     LocalizationFactory.SetCurrent(new ResourcesManagerFactory());
 }
Ejemplo n.º 7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // To add enviroment variable
            services.Configure <AppSettings>(Configuration.GetSection("ApplicationSettings"));

            //allow cors
            services.AddCors(o => o.AddPolicy("AllowAnyOriginPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            //Inject Application User Identity
            services.AddHttpContextAccessor();
            services.AddScoped <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped <IApplicationUser, ApplicationUser>();

            // Controllers
            services.AddControllers();

            // Configure EntityFramework to use an InMemory database.
            services.AddDbContext <MainDbContext>(options =>
                                                  options.UseSqlServer(
                                                      Configuration["DatabaseSettings:SqlServerConnection"],
                                                      x => x.MigrationsAssembly("VolvoCash.DistributedServices.MainContext")
                                                      ));

            // Add framework services.
            services.AddMvc(options =>
            {
                options.Filters.Add(new ValidateModelAttribute()); // an instance
                options.Filters.Add(typeof(LoggerAttribute));
                options.EnableEndpointRouting = false;
            })
            .AddFluentValidation(fv => { });

            services.AddControllers().AddNewtonsoftJson(options =>
            {
                options.SerializerSettings.ContractResolver      = new CamelCasePropertyNamesContractResolver();
                options.SerializerSettings.NullValueHandling     = NullValueHandling.Ignore;
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

            // Custom Exception and validation Filter
            services.AddScoped <CustomExceptionFilterAttribute>();

            // Application Services
            services.AddScoped <IAuthenticationAppService, AuthenticationAppService>();
            services.AddScoped <ICardAppService, CardAppService>();
            services.AddScoped <IContactAppService, ContactAppService>();
            services.AddScoped <ITransferAppService, TransferAppService>();
            services.AddScoped <IChargeAppService, ChargeAppService>();
            services.AddScoped <IClientAppService, ClientAppService>();
            services.AddScoped <ILoadAppService, LoadAppService>();

            // Domain Services
            services.AddScoped <ICardTransferService, CardTransferService>();
            services.AddScoped <ICardRechargeService, CardRechargeService>();
            services.AddScoped <ICardChargeService, CardChargeService>();

            // Repositories
            services.AddScoped <ISMSCodeRepository, SMSCodeRepository>();
            services.AddScoped <IContactRepository, ContactRepository>();
            services.AddScoped <ICardRepository, CardRepository>();
            services.AddScoped <ICardTypeRepository, CardTypeRepository>();
            services.AddScoped <IClientRepository, ClientRepository>();
            services.AddScoped <ITransferRepository, TransferRepository>();
            services.AddScoped <IChargeRepository, ChargeRepository>();
            services.AddScoped <ICashierRepository, CashierRepository>();
            services.AddScoped <IAdminRepository, AdminRepository>();

            //Common Services
            services.AddScoped <IAmazonBucketService, AmazonBucketService>();
            services.AddScoped <IUrlManager, UrlManager>();

            // Adapters
            services.AddScoped <ITypeAdapterFactory, AutomapperTypeAdapterFactory>();
            TypeAdapterFactory.SetCurrent(new AutomapperTypeAdapterFactory());

            // Configure JWTToken Authentication
            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = Configuration["JWT:Issuer"],
                    ValidAudience    = Configuration["JWT:Audience"],
                    IssuerSigningKey = new SymmetricSecurityKey(
                        Encoding.UTF8.GetBytes(Configuration["JWT:SecretKey"])
                        )
                };
            });

            // Validator
            EntityValidatorFactory.SetCurrent(new DataAnnotationsEntityValidatorFactory());

            // Localization
            LocalizationFactory.SetCurrent(new ResourcesManagerFactory());
        }
Ejemplo n.º 8
0
 public CustomerAggTests()
 {
     //Localization
     LocalizationFactory.SetCurrent(new ResourcesManagerFactory());
 }
Ejemplo n.º 9
0
 private void InitializeFactories()
 {
     //Localization
     LocalizationFactory.SetCurrent(new ResourcesManagerFactory());
 }
Ejemplo n.º 10
0
 public BankTransferServiceTests()
 {
     //Localization
     LocalizationFactory.SetCurrent(new ResourcesManagerFactory());
 }