// 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 <DataContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddDbContext <EventStoreContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddAutoMapper(); services.RegisterServices(); services.ConfigureSwagger(); // MediatR services.AddMediatR(typeof(Startup)); NativeInjectionDependency.RegisterServices(services); services.AddCors(options => { options.AddPolicy("BaseCorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); }
private static Guid CreateChurch() { var churchRepository = NativeInjectionDependency.GetInstance <IChurchRepository>(); var unitOfWork = NativeInjectionDependency.GetInstance <IUnitOfWork>(); BuilderSetup.SetCreatePersistenceMethod <Church>(churchRepository.Add); var church = Builder <Church> .CreateNew() .With(x => x.HomePhone, Telephone.Factory.CreateNew(21, "55555555")) .With(x => x.CellPhone, Telephone.Factory.CreateNew(21, "987413333")) .With(x => x.Email, Email.Factory.CreateNew($"scorponok{Guid.NewGuid()}@gmail.com")) .Persist(); unitOfWork.Commit(); return(church.Id); }
public static IServiceCollection RegisterServices(this IServiceCollection services) { NativeInjectionDependency.RegisterServices(services); return(services); }