public virtual T GetSingle(Func <T, bool> where, params Expression <Func <T, object> >[] navigationProperties) { try { T item = null; using (var context = new CheckoutDbContext()) { IQueryable <T> dbQuery = context.Set <T>(); //Apply eager loading foreach (Expression <Func <T, object> > navigationProperty in navigationProperties) { dbQuery = dbQuery.Include <T, object>(navigationProperty); } item = dbQuery //.AsNoTracking() //Don't track any changes for the selected item .FirstOrDefault(where); //Apply where clause } return(item); } catch (DbEntityValidationException ex) { Log(FleshExeptionOut(ex)); throw; } }
public static void Initialize(CheckoutDbContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.AuthenticationTokens.Any()) { return; // DB has been seeded } var auth = new AuthenticationToken() { AccessToken = "lkafjldskjfdsl", CustomerKey = "dlskfldjf", Name = "teste", RefreshToken = "aldkj", TokenType = "Tester", UserId = Guid.NewGuid(), Username = "******" }; context.AuthenticationTokens.Add(auth); context.SaveChanges(); }
public virtual IList <T> GetList(Func <T, bool> where, params Expression <Func <T, object> >[] navigationProperties) { try { List <T> list; using (var context = new CheckoutDbContext()) { IQueryable <T> dbQuery = context.Set <T>(); //Apply eager loading foreach (Expression <Func <T, object> > navigationProperty in navigationProperties) { dbQuery = dbQuery.Include <T, object>(navigationProperty); } list = dbQuery .AsNoTracking() .Where(where) .ToList <T>(); } return(list); } catch (DbEntityValidationException e) { Log(FleshExeptionOut(e)); throw; } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CheckoutDbContext context) { if (!context.Database.IsInMemory()) { context.Database.Migrate(); } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseAuthentication(); var swaggerSettings = new SwaggerSettings(); Configuration.Bind(nameof(SwaggerSettings), swaggerSettings); app.UseSwagger(options => options.RouteTemplate = swaggerSettings.JsonRoute); app.UseSwaggerUI(options => { options.SwaggerEndpoint(swaggerSettings.UIEndpoint, swaggerSettings.Description); }); app.UseMvc(); }
public CheckoutService() { var options = new DbContextOptionsBuilder <CheckoutDbContext>() .UseInMemoryDatabase("Checkout") .Options; _context = new CheckoutDbContext(options); }
public Handler( CheckoutDbContext context, IPublishEndpoint endpoint, IMapper mapper) { _context = context; _endpoint = endpoint; _mapper = mapper; }
public PaymentController(CheckoutDbContext ctx, IBankService bank, IMapper _mapper , UserManager <IdentityUser> manager, ILoggerFactory loggerFactory) { dbContext = ctx; bankService = bank; mapper = _mapper; userManager = manager; logger = loggerFactory.CreateLogger <PaymentController>(); }
public static CheckoutDbContext Create() { var options = new DbContextOptionsBuilder <CheckoutDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var context = new CheckoutDbContext(options); context.Database.EnsureCreated(); return(context); }
private void Log(string message) { using (var context = new CheckoutDbContext()) { context.Logs.Add(new Log { Level = "1", Logger = "GenericDataRepository", Message = message }); } }
public virtual void Remove(params T[] items) { try { using (var context = new CheckoutDbContext()) { foreach (T item in items) { context.Entry(item).State = EntityState.Deleted; } context.SaveChanges(); } } catch (DbEntityValidationException ex) { Log(FleshExeptionOut(ex)); throw; } }
public GetPaymentsListQueryTests(QueryTestFixture fixture) { context = fixture.Context; mapper = fixture.Mapper; }
public static void Destroy(CheckoutDbContext context) { context.Database.EnsureDeleted(); context.Dispose(); }
public AccountRepository(CheckoutDbContext context) { _context = context; }
public TransactionsHistoryRepository(CheckoutDbContext dbContext) : base(dbContext) { }
public CommandTestBase() { Context = CheckoutDbContextFactory.Create(); }
public DevBankAuthRepository(CheckoutDbContext dbContext) : base(dbContext) { }
public ShoppingCartController(CheckoutDbContext dbContext) { this.dbContext = dbContext; }
public GetPaymentDetailQueryHandler(CheckoutDbContext context, IMapper mapper) { _context = context; _mapper = mapper; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CheckoutDbContext context) { loggerFactory.AddConsole(); loggerFactory.AddDebug(); //context.Database.Migrate(); app.UseDefaultFiles(new DefaultFilesOptions() { DefaultFileNames = new List <string>() { "SignIn.html" } }); app.UseStaticFiles(); app.UseMvc(); DbInitializer.Initialize(context); }
public AuthenticationTokenRepository(CheckoutDbContext context) { this.context = context; }
public SaleRepository(CheckoutDbContext context) { this.context = context; }
public CheckoutQuery(CheckoutDbContext dbContext, ILogger <CheckoutQuery> logger) { _dbContext = dbContext; _logger = logger; }
public CheckoutCommand(CheckoutDbContext dbContext, ILogger <CheckoutCommand> logger, IMapper mapper) { _dbContext = dbContext; _logger = logger; _mapper = mapper; }