// this should also have the option of using a TestStartup (or config) to override going out to the network to spool up a DB public void InitializeFreshDatabase(IConfiguration config) { // Remove everything from database: Datastore?.Maintenance.Server.Send(new DeleteDatabasesOperation(Datastore.Database, hardDelete: true)); Datastore = StartupExtensions.InitializeRavenDbDocumentStore(config); Datastore.Maintenance.Server.Send(new CreateDatabaseOperation(new DatabaseRecord(config[StartupExtensions.ConfigKeyRavenDbDatabase]))); }
private static void ConfigureExtensions(IServiceCollection services) { StartupExtensions.AddServices(services); StartupExtensions.ConfigureDb(services); StartupExtensions.AddSwagger(services); StartupExtensions.ConfigureEventBus(services); }
/// <summary> /// Initializes a new instance of the <see cref="BaseBusinessLogic" /> class. /// BaseBusinessLogic /// </summary> /// <param name="dataContext">IDataContext</param> protected BaseBusinessLogic(IDataContext dataContext) { UnitOfWork = StartupExtensions.Resolve <IUnitOfWork>(); //Provider = StartupExtensions.Resolve<IUnitOfWorkProvider>(); DataContext = dataContext; ConfigAutoMapper(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { StartupExtensions.ConfigureSwagger(app); app.UseMvc(); app.UseStaticFiles(); app.UseCors("AllowAll"); }
private static void ConfigureExtensions(IServiceCollection services, IConfiguration configuration) { StartupExtensions.AddServices(services); StartupExtensions.AddSwagger(services); StartupExtensions.ConfigureMediator(services); StartupExtensions.ConfigureOptions(services, configuration); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { StartupExtensions.ConfigureSwagger(app); app.UseCorrelationId(new CorrelationIdOptions { UseGuidForCorrelationId = true }); app.UseMvc(); app.UseStaticFiles(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddXmlSerializerFormatters(); StartupExtensions.AddJWT(services, Configuration); services.AddDbContext <Context>(); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <Context>() .AddDefaultTokenProviders(); services.AddSwaggerGen(c => { c.SwaggerDoc("V1", new OpenApiInfo { Version = "v1", Title = "APIDesafio", }); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Description = "Entre com o Token JWT", Name = "Authorization", In = ParameterLocation.Header, Type = SecuritySchemeType.ApiKey }); c.AddSecurityRequirement(new OpenApiSecurityRequirement { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Id = "Bearer", Type = ReferenceType.SecurityScheme } }, new List <string>() } }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); services.Configure <IdentityOptions>(options => { // Default Password settings. options.Password.RequireDigit = false; options.Password.RequireLowercase = false; options.Password.RequireNonAlphanumeric = false; options.Password.RequireUppercase = false; options.Password.RequiredLength = 3; options.Password.RequiredUniqueChars = 1; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(options => { }); services.AddAutoMapper(typeof(Startup)); services.AddControllersWithViews(); services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Swagger PhotoTransport", Description = "Swagger for API Photo Transport", Version = "v1" }); options.CustomSchemaIds(x => x.FullName); }); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); services.AddDbContext <DatabaseContext>(options => options.UseSqlServer(Configuration.GetConnectionString("PhotoTransportBase"))); services.AddDefaultIdentity <Person>(options => options.SignIn.RequireConfirmedAccount = true) .AddRoles <Data.Entities.IdentityRole>() .AddEntityFrameworkStores <DatabaseContext>() .AddDefaultTokenProviders(); 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:Issuer"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"])), }; }); services.AddMvc().AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining <Startup>()); StartupExtensions.RegisterServices(services); services.AddHttpContextAccessor(); }
public void ConfigureServices(IServiceCollection services) { services.AddSingleton <IConfiguration>(Configuration); ConfigureExtensions(services); services.AddMvc(options => { options.Filters.Add <ApplicationExceptionFilter>(); }); services.AddCorrelationId(); StartupExtensions.SeedData(services); }
public when_using_startup_extensions() { var test = new TestRecordMapping(); _assembly = test.GetType().Assembly; //make sure the assembly is loaded. var types = StartupExtensions.AddRepositoryMappings(test.GetType().Assembly).Select(t => { return((Profile)Activator.CreateInstance(t)); }); mapperConfig = new MapperConfiguration(cfg => cfg.AddProfiles(types)); _mapper = mapperConfig.CreateMapper(); _services.AddSingleton <IMapper>(_mapper); _services.AddRepositoryFramework <Test>(_assembly); _container = _services.BuildServiceProvider(); }
/// <summary> /// Invokes Business Logic's method by name /// </summary> /// <typeparam name="TResponse">Method responese</typeparam> /// <param name="methodArgs">Parameters's method</param> /// <returns>Response's method</returns> public async Task <BaseServicesResult> Execute <TResponse>(params object[] methodArgs) where TResponse : BaseResponse, new() { // Init base request data BaseRequest request = ToRequest <BaseRequest>(); // Init business logic and action meta data BusinessLogic = StartupExtensions.Resolve <TBusiness>(); // Init Meta data MetaData = new BaseActionMetaData <TBusiness>(this); // TODO: Create context and using all system Context = Context; // Custom init from action Init(); // Init action utilities and logger var statusUtility = new ActionStatusUtility(request); var actionUtility = new ActionExecutionUtility(request); // TODO: Start to write log // Init default response object (equal NULL) TResponse response; if (Validate()) { response = await OnExecute <TResponse>(methodArgs); } else { response = new TResponse { Errors = actionUtility.GetErrors(ValidateResult), Success = false }; } // Build and return service message var serviceResult = new BaseServicesResult { ReturnCode = statusUtility.GetStatusCode(response), ReturnData = new BaseResponseHttpActionResult <TResponse>() { Result = response, InternalCode = (int)statusUtility.GetInternalCode(response) } }; return(serviceResult); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <EintechContext>( options => options.UseSqlServer(Configuration.GetConnectionString("EintechContext"))); services.AddControllersWithViews(); ConfigureIoC(services); //Automapper IMapper mapper = StartupExtensions.GetAutomapperConfig().CreateMapper(); services.AddSingleton(mapper); //Application Insights telemetry services.AddApplicationInsightsTelemetry(); //add health endpoint for monitoring services.AddHealthChecks(); }
/// <summary> /// Initializes a new instance of the <see cref="ProductBusinessLogic"/> class. /// </summary> /// /// <param name="dataAccess">ICMN110051DataAccess</param> /// /// <param name="dataContext">IDataContext</param> public ProductBusinessLogic(IDataContext context, IBaseRepository <Product> repository) : base(context) { _iCust = StartupExtensions.Resolve <ICustomerBusinessLogic>(); }
public T BizManager <T>() { return(StartupExtensions.Resolve <T>()); }
public BaseBizAction(IMapper autoMapper) { AutoMapper = autoMapper; UserManager = StartupExtensions.Resolve <UserManager <AppUser> >(); }
public Startup(IConfiguration configuration) { Configuration = configuration; StartupExtensions.ConfigureMapster(); }
protected BaseApiController() { DataContext = StartupExtensions.Resolve <IDataContext>(); }
public BaseRepository(DbContext context) : base(context) { _transaction = StartupExtensions.Resolve <ITransactionScope>(); }