public void Add(Customer customer) { var dbCustomer = DbMapper.ToDb <DbCustomer>(customer); Context.Customers.Add(dbCustomer); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // CONFIGURATION SETTINGS var applicationConfiguration = Configuration.GetSection("Application"); var applicationSettings = new ApplicationSettings( applicationConfiguration["DefaultNickname"], applicationConfiguration.GetValue <double>("RadiusAround"), applicationConfiguration["UploadsFolderName"]); services.AddSingleton(applicationSettings); var securityConfiguration = Configuration.GetSection("Security"); var securitySettings = new SecuritySettings( securityConfiguration["EncryptionKey"], securityConfiguration["Issue"], securityConfiguration.GetValue <TimeSpan>("ExpirationPeriod")); services.AddSingleton(securitySettings); // REPOSITORIES IShyneesRepository shyneesRepository; if (Configuration.GetValue <bool>("Database:IsInMemory")) { shyneesRepository = new InMemoryShyneesRepository(); } else { var dbConfiguration = Configuration.GetSection("Database:MongoDB"); var dbSettings = new DbSettings( dbConfiguration["ConnectionString"], dbConfiguration["Database"]); services.AddSingleton(dbSettings); var dbMapper = new DbMapper(); var dbContext = new DbContext(dbSettings); shyneesRepository = new ShyneesRepository(dbContext); } // SERVICES var shyneesService = new ShyneesService(shyneesRepository, applicationSettings); var assetsService = new AssetsService(applicationSettings); services.AddSingleton <IShyneesService>(shyneesService); services.AddSingleton <IAssetsService>(assetsService); // OTHER DEPENDENCIES services.AddScoped <ModelValidationAttribute>(); var jwtIssuer = new JwtIssuer(securitySettings); services.AddSingleton <IJwtIssuer>(jwtIssuer); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { ValidateIssuer = false, ValidateAudience = false, ValidateLifetime = true, ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey( Encoding.UTF8.GetBytes(securitySettings.EncryptionKey)) }; }); services .AddAuthorization(options => { options.DefaultPolicy = new AuthorizationPolicyBuilder(JwtBearerDefaults.AuthenticationScheme) .RequireAuthenticatedUser().Build(); }); services.AddCors(options => { options.AddPolicy("EnableCORS", builder => { builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials().Build(); }); }); services.AddMvc(config => { config.ReturnHttpNotAcceptable = true; }); services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Info { Title = Configuration["Swagger:Title"], Version = Configuration["Swagger:Version"], Description = Configuration["Swagger:Description"] }); options.AddSecurityDefinition("Bearer", new ApiKeyScheme { Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", Name = "Authorization", In = "header", Type = "apiKey" }); options.IncludeXmlComments(string.Format(@"{0}/ShyneeBackend.Application.xml", AppDomain.CurrentDomain.BaseDirectory)); options.IncludeXmlComments(string.Format(@"{0}/ShyneeBackend.Domain.xml", AppDomain.CurrentDomain.BaseDirectory)); options.DescribeAllEnumsAsStrings(); }); }
public Presenter(DbMapper dbMapper, CodeVisualizer visualizerPane, CommandBinding gotoSourceCommandBinding, CommandBinding showContextMenuCommandBinding) : base(visualizerPane, gotoSourceCommandBinding, showContextMenuCommandBinding) { DbMapper = dbMapper; RefreshView(DbMapper.TreeItems); }
protected DataRepository(DbMapper dbMapper) { _dbMapper = dbMapper; }
public DigitalCampaignDataRepository(DbMapper dbMapper) : base(dbMapper) { }
public void Add(User user) { var dbUser = DbMapper.ToDb <DbUser>(user); Context.Users.Add(dbUser); }
public ArticleService(string connectionString) { _dbMapper = new DbMapper(connectionString); }
static User() { Mapper = new DbMapper(typeof(User)); }