Beispiel #1
0
        // 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;
            });

            //Configura Mapeamento de Modelo e ViewModel por AutoMapper

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.CreateMap <MovimentoContaViewModel, MovimentoConta>();

                cfg.CreateMap <MovimentoConta, MovimentoContaViewModel>();
            });


            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            //Configura métodos de controle de Session
            services.AddDistributedMemoryCache();
            services.AddSession();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddDbContext <WebApiExemploSwaggerContext>(options =>
                                                                options.UseSqlServer(Configuration.GetConnectionString("WebApiExemploSwaggerContext")));


            #region Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1",
                             new Info
                {
                    Title       = "Api Exemplo com Swagger no CORE",
                    Version     = "v1",
                    Description = "Exemplo de API REST criada no ASP.NET CORE",
                    Contact     = new Contact
                    {
                        Name = "Daniel Silva",
                        Url  = "https://github.com/danielsilvarj"
                    }
                });
            });
            #endregion

            #region AutoMapper
            var configAutoMapper = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Produto, ProdutoCreateResponse>();
            });
            IMapper mapper = configAutoMapper.CreateMapper();
            services.AddSingleton(mapper);
            #endregion
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //===== AutoMapper =====
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapping());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);
            services.AddAutoMapper(typeof(Startup));

            services.AddControllersWithViews();
            services.AddDbContext <ProjectContext>();

            // ===== Add Identity ========
            services.AddIdentity <AppUser, IdentityRole>()
            .AddEntityFrameworkStores <ProjectContext>()
            .AddDefaultTokenProviders();
            services.AddRazorPages();

            //=====Fluent Validation =======
            services.AddMvc(options => { options.Filters.Add <ValidationFilter>(); options.EnableEndpointRouting = false; })
            .AddFluentValidation(opt => { opt.RegisterValidatorsFromAssemblyContaining <Startup>(); });
            services.AddSignalR();

            //===== Google Authentication ======
            services.AddAuthentication()
            .AddGoogle(x =>
            {
                x.ClientId     = Configuration["GoogleClientId"];
                x.ClientSecret = Configuration["GoogleClientSecret"];
            });
            services.AddSmidge(Configuration.GetSection("smidge"));
        }
Beispiel #4
0
        // 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;
            });

            Init.ConfigureServices(services, Configuration.GetConnectionString("DefaultConnection"));

            services.Configure <EmailSettings>(Configuration.GetSection("EmailSettings"));
            services.AddTransient <IEmailSender, AuthMessageSender>();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperProfile());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddAutoMapper();

            //
        }
        public async Task <List <FooDto> > RunAutomapper()
        {
            return(await Task.Run(() =>
            {
                using (var bench = new Benchmark($"AutoMapper {NumberObject} object:"))
                {
                    var configuration = new AutoMapper.MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <JObject, FooDto>();
                    });

                    // only during development, validate your mappings; remove it before release
                    // configuration.AssertConfigurationIsValid();

                    var mapper = configuration.CreateMapper();

                    var fooDtos = new List <FooDto>();

                    DynFoos.ForEach(foo =>
                    {
                        fooDtos.Add(mapper.Map <FooDto>(foo as JObject));
                    });

                    return fooDtos;
                }
            }));
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(
                                                             Configuration["Data:SportUnite:ConnectionString"]));
            services.AddTransient <ISportEventManager, SportEventManager>();
            services.AddTransient <ISportEventRepository, EfSportEventRepository>();
            services.AddTransient <IBuildingManager, EFBuildingManager>();
            services.AddTransient <IBuildingRepository, EFBuildingRepository>();
            services.AddTransient <IHallManager, EFHallManager>();
            services.AddTransient <IHallRepository, EFHallRepository>();
            services.AddTransient <ISportRepository, EFSportRepository>();
            services.AddTransient <ISportManager, SportManager>();


            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperProfileConfiguration());
            });

            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddMvc().AddJsonOptions(options => {
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            });

            services.AddCors();
        }
Beispiel #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <AppDbContext>(options =>
            {
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnectionString"));
            });
            services.AddSingleton <IActionContextAccessor, ActionContextAccessor>();

            services.AddScoped <IRepository <ContactsDataModel>, GenericRepository <ContactsDataModel> >();
            services.AddScoped <IContactRepository, ContactRepository>();
            services.AddScoped <IUrlHelper, UrlHelper>(x =>
            {
                var actionContext = x.GetService <IActionContextAccessor>().ActionContext;
                return(new UrlHelper(actionContext));
            });
            services.AddScoped <IMapper, Mapper>();

            services.AddMvc();

            var config = new AutoMapper.MapperConfiguration(c =>
            {
                c.AddProfile(new ApplicationProfile());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);
        }
        public void InjectAutoMapper()
        {
            // Assume we have multiple Profile classes.  We'll load them individually to create multiple mappers for our factory
            var     mapperFactory   = new MapperFactory();
            IMapper defaultMapper   = null;
            var     currentAssembly = Assembly.GetEntryAssembly();
            var     types           = currentAssembly.GetTypes().Where(x => x.GetTypeInfo().IsClass&& x.IsAssignableFrom(x) && x.GetTypeInfo().BaseType == typeof(Profile)).ToList();

            foreach (var type in types)
            {
                var profileName = string.Empty;
                var config      = new AutoMapper.MapperConfiguration(cfg =>
                {
                    var profile = (Profile)Activator.CreateInstance(type);
                    profileName = profile.ProfileName;
                    cfg.AddProfile(profile);
                });

                var mapper = config.CreateMapper();
                mapperFactory.Mappers.Add(profileName, mapper);

                // If we still want normal functionality with a default injected IMapper
                if (defaultMapper == null)
                {
                    defaultMapper = mapper;
                    _container.Register(() => defaultMapper);
                }
            }

            _container.Register <IMapperFactory>(() => mapperFactory);
        }
Beispiel #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var connection = @"Server=(localdb)\mssqllocaldb;Database=DesafioQuiz;Trusted_Connection=True;";

            services.AddDbContext <DesafioQuizContext>(options => options.UseSqlServer(connection));


            services.AddScoped <IRepliesRepository, RepliesRepository>();
            services.AddScoped <IRepliesService, RepliesService>();
            services.AddScoped <IQuestionRepository, QuestionRepository>();
            services.AddScoped <IQuestionService, QuestionService>();


            var config = new AutoMapper.MapperConfiguration(map =>
            {
                map.CreateMap <QuestionViewModel, Question>().ReverseMap();
                map.CreateMap <RepliesViewModel, Replies>().ReverseMap();
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);
        }
Beispiel #10
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Application", Version = "v1"
                });
            });

            services.AddDbContext <MyContext>(opt => opt.UseInMemoryDatabase("dbapi").ConfigureWarnings(x => x.Ignore(InMemoryEventId.TransactionIgnoredWarning)));

            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);
        }
Beispiel #11
0
        public void ConfigureServices(IServiceCollection services)
        {
            //services.AddDbContext<BankingContext>(options => options.UseMySql(Configuration.GetConnectionString("MySqlConnection")));

            var MySqlConnection = Environment.GetEnvironmentVariable("MySqlConnection");

            services.AddDbContext <BankingContext>(options => options.UseMySql(MySqlConnection));

            services.AddScoped <ICustomerApplicationService, CustomerApplicationService>();
            services.AddScoped <IBankAccountApplicationService, BankAccountApplicationService>();
            services.AddScoped <ITransactionApplicationService, TransactionApplicationService>();
            services.AddScoped <ISecurityApplicationService, SecurityApplicationService>();
            services.AddScoped <IUnitOfWork, UnitOfWork>();
            services.AddScoped <IBankAccountRepository, BankAccountRepository>();
            services.AddScoped <ICustomerRepository, CustomerRepository>();
            services.AddCors();

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutomapperProfile());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddTransient <DbInitializer>();
        }
Beispiel #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            ConfigureRepository.ConfigureDependenciesRepository(services);
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version = "v1",
                    Title   = "Prova NaPista",
                    Contact = new OpenApiContact
                    {
                        Name  = "Raul Rodrigo Silva de Andrade",
                        Email = "*****@*****.**",
                    }
                });
                var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                c.IncludeXmlComments(xmlPath);
            });
        }
        protected IMapper GetConfiguration()
        {
            var config = new AutoMapper.MapperConfiguration(cfg => {
                cfg.CreateMap <ArticleDTO, Article>().ForMember(dest =>
                                                                dest.ArticleTags, act => act.MapFrom(src => src.ArticleTags));

                cfg.CreateMap <Article, ArticleDTO>().ForMember(dest =>
                                                                dest.ArticleTags, act => act.MapFrom(src => src.ArticleTags));

                cfg.CreateMap <TagDTO, Tag>().ForMember(dest =>
                                                        dest.ArticleTags, act => act.MapFrom(src => src.ArticleTags));

                cfg.CreateMap <Tag, TagDTO>().ForMember(dest =>
                                                        dest.ArticleTags, act => act.MapFrom(src => src.ArticleTags));

                cfg.CreateMap <CategoryDTO, Category>();

                cfg.CreateMap <Category, CategoryDTO>();

                cfg.CreateMap <ArticleTags, ArticleTagsDTO>();
                cfg.CreateMap <ArticleTagsDTO, ArticleTags>();
            });
            IMapper iMapper = config.CreateMapper();

            return(iMapper);
        }
Beispiel #14
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Set to return json
            services.AddMvc(options => { options.Filters.Add(new ProducesAttribute("application/json")); });

            // NOTE: what does AddOptions do?
            services.AddOptions();

            //ConfigurationForAutoMapper
            var config = new AutoMapper.MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperConfigurationProfile()); });
            var mapper = config.CreateMapper();

            services.AddSingleton <IMapper>(mapper);

            services.Configure <DatabaseSettings>(c =>
            {
                c.ConnectionString = Configuration.GetSection("MongoConnection:ConnectionString").Value;
                c.Database         = Configuration.GetSection("MongoConnection:Database").Value;
            });

            // Puts the Database Setting in Scope for db Context
            services.AddScoped(cfg => cfg.GetService <IOptions <DatabaseSettings> >().Value);

            services.AddScoped <DBContext, DBContext>();
            services.AddScoped <IRespository, MongoRepository>();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "Customer Management Service", Version = "v1"
                });
            });
        }
Beispiel #15
0
        public static IMapper CreateConfig()
        {
            var config = new AutoMapper.MapperConfiguration
                             (cfg => cfg.AddProfile(new DomainToViewModelProfile()));

            return(config.CreateMapper());
        }
Beispiel #16
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().AddJsonOptions(opt => opt.SerializerSettings.ContractResolver = new DefaultContractResolver());
            services.AddCors(options => {
                options.AddPolicy("AllowAllHeaders",
                                  builder => {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod();
                });
            });

            services.AddAuthorization(options => {
                options.DefaultPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme)
                                        .RequireAuthenticatedUser()
                                        .Build();
            });

            services.AddAuthentication(o => {
                o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                o.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
                o.DefaultSignInScheme       = JwtBearerDefaults.AuthenticationScheme;
            }).AddJwtBearer(options => {
                options.TokenValidationParameters = new TokenValidationParameters {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = "test",
                    ValidAudience    = "test",
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("secretesecretesecretesecretesecretesecrete"))
                };
            });


            services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(@"Data Source=localhost\SQLexpress,1433;Initial Catalog=Kanban_Dev;User ID=sa;Password=e58@t4Ie"));

            services.AddIdentity <UserEntity, KanbanRoles>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            services.AddTransient <IUserRepository, SqlUserRepository>();
            services.AddTransient <UserService, UserService>();
            services.AddTransient <IProjectRepository, SqlProjectRepository>();
            services.AddTransient <ProjectService, ProjectService>();
            services.AddTransient <ITaskRepository, SqlTaskRepository>();
            services.AddTransient <TaskService, TaskService>();
            services.AddMvc(options =>
            {
                options.Filters.Add(new KanbanExceptionFilterAttribute());
                options.Filters.Add(new ApiValidationFilterAttribute());
            });

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new AutoMapperProfileConfiguration());
                cfg.AddProfile(new SqlMapperConfiguraiton());
            });

            InitializeAutoMapper();
        }
Beispiel #17
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <SqlServerDbContext>(c =>
                                                       c.UseSqlServer(Configuration.GetConnectionString("DbConnection")), ServiceLifetime.Singleton);


            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile <UserMapper>();
            });
            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);


            services.ResolveDependencies();

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "ProjetoDDD API", Version = "v1"
                });
            });

            services.AddControllers();
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureRepository.ConfigureDependenciesRepository(services);
            ConfigureService.ConfigureDependenciesService(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DTOToModelProfile());
                cfg.AddProfile(new EntityToDTOProfile());
                cfg.AddProfile(new EntityToModelProfile());
            });
            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Title       = "Market Api",
                    Version     = "v1",
                    Description = "Market Api with architecture DDD",
                    Contact     = new OpenApiContact
                    {
                        Name  = "Roberta Suélen Rodrigues Alves",
                        Email = "*****@*****.**",
                        Url   = new Uri("https://www.linkedin.com/in/roberta-su%C3%A9len-rodrigues-alves-223733116")
                    }
                });
            });
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddDbContext <TripPlannerDBContext>(options => options.UseInMemoryDatabase(databaseName: "TripPlannerDB"));


            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(jwtBearerOptions =>
            {
                jwtBearerOptions.TokenValidationParameters = new TokenValidationParameters()
                {
                    ValidateActor            = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    ValidIssuer      = Configuration[WebConfig.TOKEN_ISSUER],
                    ValidAudience    = Configuration[WebConfig.TOKEN_AUDIENCE],
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration[WebConfig.TOKEN_SIGNING_KEY]))
                };
            });

            var config = new AutoMapper.MapperConfiguration(c => {
                c.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);
        }
        public Mapeamento()
        {
            AutoMapper.MapperConfiguration configuration = new AutoMapper.MapperConfiguration(cfg => {
                cfg.CreateMap <UserRequest, Usuario>()
                .ForPath(e => e.DataInclusao, p => p.MapFrom(prop => DateTime.Now))
                .ForPath(e => e.User, p => p.MapFrom(prop => prop.NomeUser))
                .ForPath(e => e.Password, p => p.MapFrom(prop => prop.Senha.ConvertToMD5()))
                .ForPath(e => e.Situacao, p => p.MapFrom(prop => true));

                cfg.CreateMap <UserRequest, Salario>()
                .ForPath(e => e.SoudoBruto, p => p.MapFrom(prop => Convert.ToDouble(prop.SoudoBruto)))
                .ForPath(e => e.SoudoLiquido, p => p.MapFrom(prop => Convert.ToDouble(prop.SoudoLiquido)))
                .ForPath(e => e.Situacao, p => p.MapFrom(prop => true));

                cfg.CreateMap <LivroRequest, Livro>()
                .ForPath(e => e.NumPaginas, p => p.MapFrom(prop => Convert.ToDouble(prop.NumPaginas)))
                .ForPath(e => e.Valor, p => p.MapFrom(prop => Convert.ToDouble(prop.Valor)))
                .ForPath(e => e.IdCategoria, p => p.MapFrom(prop => Convert.ToInt32(prop.IdCategoria)))
                .ForPath(e => e.Situacao, p => p.MapFrom(prop => true))
                .ForPath(e => e.DataInclusao, p => p.MapFrom(prop => DateTime.Now))
                .ForPath(e => e.Situacao, p => p.MapFrom(prop => true));

                cfg.CreateMap <Usuario, UserResponse>();

                cfg.CreateMap <Livro, ListLivroResponse>()
                .ForPath(e => e.IdCategoria, p => p.MapFrom(prop => Convert.ToInt32(prop.IdCategoria)))
                .ForPath(e => e.Categoria, p => p.MapFrom(prop => prop.LivroCategoria.DescricaoCategoria));

                cfg.CreateMap <LivroRequest, Livro>();
            });

            this._Mapper = configuration.CreateMapper();
        }
Beispiel #21
0
        public TestBase()
        {
            // initalize environment variable
            using (var file = File.OpenText("Properties\\launchSettings.json"))
            {
                var reader  = new JsonTextReader(file);
                var jObject = JObject.Load(reader);

                var variables = jObject
                                .GetValue("profiles")
                                //select a proper profile here
                                .SelectMany(profiles => profiles.Children())
                                .SelectMany(profile => profile.Children <JProperty>())
                                .Where(prop => prop.Name == "environmentVariables")
                                .SelectMany(prop => prop.Value.Children <JProperty>())
                                .ToList();

                foreach (var variable in variables)
                {
                    Environment.SetEnvironmentVariable(variable.Name, variable.Value.ToString());
                }
            }
            _config = new EnvironmentConfigurationService();
            // initailize mapper
            _mapperConfiguration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new NDIDMapperConfiguration());
            });
        }
Beispiel #22
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <Context>(options => options.UseNpgsql(Configuration.GetConnectionString("DeliverItContext")));

            services.AddControllers();

            ConfigureRepository.ConfigureDependecyService(services);
            ConfigureService.ConfigureDependencysService(services);

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToModelProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "test_deliverit", Version = "v1"
                });
            });
        }
Beispiel #23
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            ConfigureService.ConfigureDependenciesService(services);
            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new DtoToProfile());
                cfg.AddProfile(new EntityToDtoProfile());
                cfg.AddProfile(new ModelToEntityProfile());
            });

            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo
                {
                    Version = "v1",
                    Title   = "Api para processar pagamento",
                    Contact = new OpenApiContact
                    {
                        Name  = "Raul Rodrigo Silva de Andrade",
                        Email = "*****@*****.**",
                        Url   = new Uri("http://www.mfrinfo.com.br")
                    },
                });
            });
        }
Beispiel #24
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAuthentication("CookieAuth")
            .AddCookie("CookieAuth", config =>
            {
                config.Cookie.Name = "LoginCookie";
                config.LoginPath   = "/Home/NotFound";
            });

            services.AddControllersWithViews();
            //services.AddSingleton<AuthenticateUser>();
            services.Configure <EmailOptions>(Configuration.GetSection("EmailOptions"));
            //services.AddSingleton(Configuration);

            services.AddMvc()
            .SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0);
            services.AddDbContext <JitContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("JITConnectionString")));
            services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new JitRepositoryMappingProfile());
                cfg.AddProfile(new JitClientMappingProfile());
            });
            var mapper = config.CreateMapper();

            services.AddSingleton(mapper);
            services.AddCloudscribePagination();

            services.AddRepositoriesCollection();
            services.AddBusinessServicesCollection();
        }
Beispiel #25
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddSignalR();

            var config = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.CreateMap <ElementModel, Element>().ReverseMap();
                cfg.CreateMap <ElementTypeModel, ElementType>().ReverseMap();
            });
            IMapper mapper = config.CreateMapper();

            services.AddSingleton(mapper);

            services.AddSwaggerGen(c => {
                c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo {
                    Title = "Employee API", Version = "V1"
                });
            });


            services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));
        }
Beispiel #26
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader()
                .AllowCredentials();
            }));

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.Configure <MvcOptions>(options =>
            {
                options.Filters.Add(new CorsAuthorizationFilterFactory("MyPolicy"));
            });

            var connectionString = Configuration["connectionStrings:recipeBookDBConnectionString"];

            services.AddDbContext <RecipeBookContext>(o => o.UseSqlServer(connectionString));

            // register the service
            services.AddScoped <IRecipeBookService, RecipeBookService>();

            var mappingConfig = new AutoMapper.MapperConfiguration(cfg =>
            {
                // cfg.CreateMap<Recipe, RecipeViewModel>();
                cfg.AddAdminMapping();
            });

            services.AddSingleton(x => mappingConfig.CreateMapper());
        }
Beispiel #27
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            // Register the Swagger generator, defining 1 or more Swagger documents
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info {
                    Title = "NDID IDP POC APP", Version = "v1"
                });
            });

            // Enable CORS
            services.AddCors();

            // Enable Automapper
            _mapperConfiguration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new NDIDMapperConfiguration());
            });

            // Add application services via dependencies injection
            services.AddTransient <IMapper>(sp => _mapperConfiguration.CreateMapper());
            services.AddTransient <IConfigurationService, EnvironmentConfigurationService>();
            services.AddTransient <INDIDService, NDIDService>();
            services.AddTransient <IDPKIService, FileBasedDPKIServicec>();
            services.AddSingleton <IPersistanceStorageService, LiteDBStorageService>();
        }
Beispiel #28
0
        protected void Initialize()
        {
            _options = new CoreOptions();
            _mill    = new LoggerFactory();

            Mapper = new AutoMapper.MapperConfiguration(cfg => {
                cfg.AddTopoMojoMaps();
            }).CreateMapper();

            Cache       = new StubDistributedCache();
            MemoryCache = new StubMemoryCache();

            _dbOptions = new DbContextOptionsBuilder <TopoMojoDbContext>()
                         .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                         .Options;

            using (TopoMojoDbContext ctx = new TopoMojoDbContext(_dbOptions))
            {
                ctx.Database.EnsureDeleted();
                ctx.Database.EnsureCreated();
                _user = new TopoMojo.Models.User {
                    Id = 1, Name = "tester"
                };
                _ur = new IdentityResolver(_user);
            }
        }
Beispiel #29
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo {
                    Title = "Corp.System.Hexagonal.Orders.Adapters.WebAPI", Version = "v1"
                });
            });

            //  Application
            // services.AddOrdersModuleDependency(Configuration);
            services.AddOrdersModuleDependency();

            // services.AddOrdersModuleDependency(opt => opt.UseInMemoryDatabase(databaseName: "TestCustomerContext"));

            //  AutoMapper
            var mapConfig = new AutoMapper.MapperConfiguration(cfg =>
            {
                cfg.AddProfile <DtoXModelProfile>();
            });

            mapConfig.AssertConfigurationIsValid();
            services.AddSingleton <IMapper>(mapConfig.CreateMapper());
        }
        public async void Add_Products_With_Success()
        {
            var container = new Container(cfg =>
            {
                cfg.Scan(scanner =>
                {
                    scanner.AssemblyContainingType(typeof(AddProductCommandHandler));
                    scanner.IncludeNamespaceContainingType <AddProductCommandHandler>();
                    scanner.WithDefaultConventions();
                    scanner.AddAllTypesOf(typeof(IRequestHandler <,>));
                });

                cfg.For <ServiceFactory>().Use <ServiceFactory>(ctx => t => ctx.GetInstance(t));
                cfg.For <IMediator>().Use <Mediator>();
                cfg.For <IProductRepository>().Use(x => mock.Object);

                var config = new AutoMapper.MapperConfiguration(configuration =>
                {
                    configuration.AddProfile(new CommandToDomainMapping());
                });


                cfg.For <IMapper>().Use(() => config.CreateMapper());
            });

            mock.Setup(x => x.Add(It.IsAny <Product>())).Verifiable();

            var mediator = container.GetInstance <IMediator>();



            await mediator.Send(new AddProductCommand
            {
            });
        }