// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PaymentDbContext dbContext, UserManager <IdentityUser> userManager) { app.UseStaticFiles(); app.UseSwagger(); app.UseHsts(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Payment.API v1"); c.RoutePrefix = string.Empty; c.InjectStylesheet("/swagger-ui/Custom.css"); c.InjectJavascript("/swagger-ui/Custom.js"); c.DefaultModelRendering(ModelRendering.Example); c.DisplayRequestDuration(); c.ShowExtensions(); c.EnableFilter(); }); StartupDbInitializer.SeedData(dbContext, userManager); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
private void Install() { services.AddTransient <IDbContextFactory, DbContextFactory>(); services.AddTransient <IUnitOfWorkFactory, UnitOfWorkFactory>(); services.AddTransient <IJsonSerializer, JsonSerializer>(); services.AddTransient <IXmlSerializer, XmlSerializer>(); services.AddTransient <IClassMapper, ClassMapper>(); services.AddTransient <ILogger, Log4NetLogger>(); Log4NetLogger.Init(); services.AddTransient <IPaymentService, PaymentService>(); services.AddTransient <BankDomainService>(); services.AddTransient <ProviderDomainService>(); services.AddTransient <IBankBinRepository, BankBinRepository>(); services.AddTransient <IBankProviderRepository, BankProviderRepository>(); services.AddTransient <IProviderRepository, ProviderRepository>(); services.AddTransient <IBankValidation, BankValidation>(); ContractToDomainModelMapping(); DomainToContractModelMapping(); using (PaymentDbContext context = new PaymentDbContext()) { context.Database.Migrate(); } }
public PaymentService(IConfiguration config, IOptions <Dto.AppSettings> appSettings, IMapper mapper, PaymentDbContext dbContext) { _config = config; _appSettings = appSettings.Value; _mapper = mapper; _paymentDbContext = dbContext; }
protected PaymentRepository GetRepository() { var options = CreateNewContextOptions(); _dbContext = new PaymentDbContext(options); return(new PaymentRepository(_dbContext)); }
public static PaymentsRepository Create(PaymentDbContext context) { context.Database.EnsureCreated(); var paymentRepo = new PaymentsRepository(context); return(paymentRepo); }
public static void ApplyMigrations(PaymentDbContext context) { if (context.Database.GetPendingMigrations().Any()) { context.Database.Migrate(); } }
public PaymentTestFixture() { var options = new DbContextOptionsBuilder <PaymentDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; Context = new PaymentDbContext(options); repo = PaymentContextFactory.Create(Context); }
public int Processpayment(PaymentDetails paydels) { PaymentDbContext paymentDb = new PaymentDbContext(); paymentDb.paymentdetails.Add(paydels); return(paymentDb.SaveChanges()); //if(i>0) // return 'Payment is Process' }
public static PaymentDbContext BuildContext(string databaseName) { var options = new DbContextOptionsBuilder <PaymentDbContext>() .UseInMemoryDatabase(databaseName).Options; var dbContext = new PaymentDbContext(options); return(dbContext); }
public virtual Task Setup() { var dbOptions = new DbContextOptionsBuilder <PaymentDbContext>() .UseInMemoryDatabase(databaseName: "PaymentDb") .Options; EncryptionService = new EncryptionService(); PaymentDb = new PaymentDbContext(dbOptions); return(Task.CompletedTask); }
public void InitializeDbForTests(PaymentDbContext db) { Fixture fixture = new Fixture(); Payment = fixture.Build <Payment>() .With(p => p.CardNumber, "4111111111111111").Create(); db.Payments.Add(Payment); db.SaveChanges(); }
public PaymentRepositoryShould() { var options = new DbContextOptionsBuilder <PaymentDbContext>() .UseInMemoryDatabase("TestPaymentDatabase") .Options; _paymentContext = new PaymentDbContext(options); _paymentRepository = new PaymentRepository(_paymentContext); _fixture = new Fixture(); }
protected RepositoryWrapper GetRepository(IHttpClientFactory httpClientFactory) { var paymentOptions = CreatePaymentContextOptions(); var userOptions = CreateUserContextOptions(); _paymentDbContext = new PaymentDbContext(paymentOptions); _userDbContext = new UserDbContext(userOptions); return(new RepositoryWrapper(_paymentDbContext, _userDbContext, httpClientFactory)); }
public TransactionsController(ILogger <TransactionsController> logger, PaymentDbContext dbContext, CancellationTaskRabbitMqMessageSender messageSender, IdentityGenerator generator, IConfiguration configuration) { Logger = logger; DbContext = dbContext; MessageSender = messageSender; Generator = generator; Configuration = configuration; }
public RepositoryWrapper(PaymentDbContext paymentContext, UserDbContext userDbContext, IHttpClientFactory httpClientFactory) { _paymentContext = paymentContext ?? throw new ArgumentNullException(nameof(paymentContext)); _userDbContext = userDbContext ?? throw new ArgumentNullException(nameof(userDbContext)); _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); Users = new UserRepository(_userDbContext); Cards = new CardRepository(_paymentContext); PaymentGateways = new PaymentGatewayRepository(_paymentContext, _httpClientFactory); }
public void DownloadPdfPayment(int paymentId) { Payment payment; using (var paymentCtx = new PaymentDbContext("test")) { payment = paymentCtx.Payments.Where(p => p.Id == paymentId).ToList().First(); } if (payment == null) { throw new Exception("No payment was found"); } // TODO: make logic to download payment }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_paymentContext != null) { _paymentContext.Dispose(); _paymentContext = null; } if (_cancellationTokenSource != null) { _cancellationTokenSource.Dispose(); _cancellationTokenSource = null; } } }
public bool CreatePayment(Payment payment) { try { using (var transactionCtx = new PaymentDbContext(GetConnectionString())) { transactionCtx.Payments.Add(payment); transactionCtx.SaveChanges(); } } catch (Exception e) { Console.WriteLine(e); return(false); } return(true); }
public override List <Payment> GetAll(int id = 0) { List <Payment> payments; try { using (var paymentCtx = new PaymentDbContext(GetConnectionString())) { payments = paymentCtx.Payments.Where(p => p.UserId == id).ToList(); } } catch (Exception e) { Console.WriteLine(e); throw; } return(payments); }
public static async Task Seed(PaymentDbContext dbContext) { await dbContext.Set <PaymentMethod>().AddAsync(new PaymentMethod { Id = new System.Guid("c50683db-d227-4856-b777-ea07e030d926"), Code = "AM" // AMEX }); await dbContext.Set <PaymentMethod>().AddAsync(new PaymentMethod { Id = new System.Guid("aae5885e-682b-42e8-b230-7ad2dad55331"), Code = "MC" // MasterCard }); await dbContext.Set <PaymentMethod>().AddAsync(new PaymentMethod { Id = new System.Guid("7fa09019-f0c4-4479-b9fd-fae9652c4901"), Code = "CSH" // Cash }); await dbContext.SaveChangesAsync(); }
public ContactSMSController(PaymentDbContext context) { _context = context; }
public PaymentRepository(PaymentDbContext paymentDbContext) { _paymentDbContext = paymentDbContext; }
public CardRepository(PaymentDbContext context) { _db = context; }
public PaymentService(PaymentDbContext context, IMessageSession messageSession) { this.context = context; this.messageSession = messageSession; }
public RequestRepository(PaymentDbContext context) { _db = context; }
public UserRepository(PaymentDbContext context, ApplicationUserManager userManager) { _db = context; _userManager = userManager; }
public PaymentRepository(PaymentDbContext context) { _context = context; }
public AccountRepository(PaymentDbContext context) { _db = context; }
public TransactionController(ILogger <TransactionController> logger, PaymentDbContext dbContext) { Logger = logger; DbContext = dbContext; }
public MessageRepository(PaymentDbContext context) { _db = context; }
public PaymentDetailsController(PaymentDbContext context) { _context = context; }
public PaymentController(PaymentDbContext db) { this.db = db; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILog logger, PaymentDbContext db) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // Add the middleware the handle the exception at global level app.ConfigureExceptionHandler(logger); // include the routing middleware app.UseRouting(); // include the cors middleware app.UseCors(); // include the authentication middleware app.UseAuthorization(); // use for routing end points app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); // Check is any migration is pending to make impact on database if (db != null && db.Database.GetPendingMigrations().Any()) { db.Database.Migrate(); } // use the swagger middleware app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My Test1 Api v1"); }); }
public PaymentController(PaymentDbContext paymentDbContext, ICapPublisher capBus, ILogger <PaymentController> logger) { _paymentDbContext = paymentDbContext; _capBus = capBus; _logger = logger; }
public CountriesController(PaymentDbContext context) { _context = context; }
public EFRepositoryFactory(string connectionName) { _context = new PaymentDbContext(connectionName); }