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;
            }
        }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 4
0
        // 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();
        }
Esempio n. 5
0
        public CheckoutService()
        {
            var options = new DbContextOptionsBuilder <CheckoutDbContext>()
                          .UseInMemoryDatabase("Checkout")
                          .Options;

            _context = new CheckoutDbContext(options);
        }
Esempio n. 6
0
 public Handler(
     CheckoutDbContext context,
     IPublishEndpoint endpoint,
     IMapper mapper)
 {
     _context  = context;
     _endpoint = endpoint;
     _mapper   = mapper;
 }
Esempio n. 7
0
 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>();
 }
Esempio n. 8
0
        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;
 }
Esempio n. 12
0
 public static void Destroy(CheckoutDbContext context)
 {
     context.Database.EnsureDeleted();
     context.Dispose();
 }
Esempio n. 13
0
 public AccountRepository(CheckoutDbContext context)
 {
     _context = context;
 }
 public TransactionsHistoryRepository(CheckoutDbContext dbContext)
     : base(dbContext)
 {
 }
Esempio n. 15
0
 public CommandTestBase()
 {
     Context = CheckoutDbContextFactory.Create();
 }
Esempio n. 16
0
 public DevBankAuthRepository(CheckoutDbContext dbContext)
     : base(dbContext)
 {
 }
 public ShoppingCartController(CheckoutDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
Esempio n. 18
0
 public GetPaymentDetailQueryHandler(CheckoutDbContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Esempio n. 19
0
        // 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);
        }
Esempio n. 20
0
 public AuthenticationTokenRepository(CheckoutDbContext context)
 {
     this.context = context;
 }
Esempio n. 21
0
 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;
 }