コード例 #1
0
ファイル: Startup.cs プロジェクト: MJoneidi/PaymentGateway
        // 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();
            });
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
ファイル: PaymentService.cs プロジェクト: giron85/FOK
 public PaymentService(IConfiguration config, IOptions <Dto.AppSettings> appSettings, IMapper mapper, PaymentDbContext dbContext)
 {
     _config           = config;
     _appSettings      = appSettings.Value;
     _mapper           = mapper;
     _paymentDbContext = dbContext;
 }
コード例 #4
0
        protected PaymentRepository GetRepository()
        {
            var options = CreateNewContextOptions();

            _dbContext = new PaymentDbContext(options);
            return(new PaymentRepository(_dbContext));
        }
コード例 #5
0
        public static PaymentsRepository Create(PaymentDbContext context)
        {
            context.Database.EnsureCreated();
            var paymentRepo = new PaymentsRepository(context);

            return(paymentRepo);
        }
コード例 #6
0
ファイル: DbContext.cs プロジェクト: abdullahgb/Microservices
 public static void ApplyMigrations(PaymentDbContext context)
 {
     if (context.Database.GetPendingMigrations().Any())
     {
         context.Database.Migrate();
     }
 }
コード例 #7
0
        public PaymentTestFixture()
        {
            var options = new DbContextOptionsBuilder <PaymentDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            Context = new PaymentDbContext(options);
            repo    = PaymentContextFactory.Create(Context);
        }
コード例 #8
0
        public int Processpayment(PaymentDetails paydels)
        {
            PaymentDbContext paymentDb = new PaymentDbContext();

            paymentDb.paymentdetails.Add(paydels);
            return(paymentDb.SaveChanges());
            //if(i>0)
            //    return 'Payment is Process'
        }
コード例 #9
0
        public static PaymentDbContext BuildContext(string databaseName)
        {
            var options = new DbContextOptionsBuilder <PaymentDbContext>()
                          .UseInMemoryDatabase(databaseName).Options;

            var dbContext = new PaymentDbContext(options);

            return(dbContext);
        }
コード例 #10
0
        public virtual Task Setup()
        {
            var dbOptions = new DbContextOptionsBuilder <PaymentDbContext>()
                            .UseInMemoryDatabase(databaseName: "PaymentDb")
                            .Options;

            EncryptionService = new EncryptionService();
            PaymentDb         = new PaymentDbContext(dbOptions);
            return(Task.CompletedTask);
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        public PaymentRepositoryShould()
        {
            var options = new DbContextOptionsBuilder <PaymentDbContext>()
                          .UseInMemoryDatabase("TestPaymentDatabase")
                          .Options;

            _paymentContext = new PaymentDbContext(options);

            _paymentRepository = new PaymentRepository(_paymentContext);
            _fixture           = new Fixture();
        }
コード例 #13
0
        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));
        }
コード例 #14
0
 public TransactionsController(ILogger <TransactionsController> logger,
                               PaymentDbContext dbContext,
                               CancellationTaskRabbitMqMessageSender messageSender,
                               IdentityGenerator generator,
                               IConfiguration configuration)
 {
     Logger        = logger;
     DbContext     = dbContext;
     MessageSender = messageSender;
     Generator     = generator;
     Configuration = configuration;
 }
コード例 #15
0
        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);
        }
コード例 #16
0
        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
        }
コード例 #17
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_paymentContext != null)
         {
             _paymentContext.Dispose();
             _paymentContext = null;
         }
         if (_cancellationTokenSource != null)
         {
             _cancellationTokenSource.Dispose();
             _cancellationTokenSource = null;
         }
     }
 }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        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();
        }
コード例 #21
0
 public ContactSMSController(PaymentDbContext context)
 {
     _context = context;
 }
コード例 #22
0
 public PaymentRepository(PaymentDbContext paymentDbContext)
 {
     _paymentDbContext = paymentDbContext;
 }
コード例 #23
0
 public CardRepository(PaymentDbContext context)
 {
     _db = context;
 }
コード例 #24
0
 public PaymentService(PaymentDbContext context, IMessageSession messageSession)
 {
     this.context        = context;
     this.messageSession = messageSession;
 }
コード例 #25
0
 public RequestRepository(PaymentDbContext context)
 {
     _db = context;
 }
コード例 #26
0
 public UserRepository(PaymentDbContext context, 
     ApplicationUserManager userManager)
 {
     _db = context;
     _userManager = userManager;
 }
コード例 #27
0
 public PaymentRepository(PaymentDbContext context)
 {
     _context = context;
 }
コード例 #28
0
 public AccountRepository(PaymentDbContext context)
 {
     _db = context;
 }
コード例 #29
0
 public TransactionController(ILogger <TransactionController> logger, PaymentDbContext dbContext)
 {
     Logger    = logger;
     DbContext = dbContext;
 }
コード例 #30
0
 public MessageRepository(PaymentDbContext context)
 {
     _db = context;
 }
コード例 #31
0
 public PaymentDetailsController(PaymentDbContext context)
 {
     _context = context;
 }
コード例 #32
0
 public PaymentController(PaymentDbContext db)
 {
     this.db = db;
 }
コード例 #33
0
        // 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");
            });
        }
コード例 #34
0
 public PaymentController(PaymentDbContext paymentDbContext, ICapPublisher capBus, ILogger <PaymentController> logger)
 {
     _paymentDbContext = paymentDbContext;
     _capBus           = capBus;
     _logger           = logger;
 }
コード例 #35
0
 public CountriesController(PaymentDbContext context)
 {
     _context = context;
 }
コード例 #36
0
 public EFRepositoryFactory(string connectionName)
 {
     _context = new PaymentDbContext(connectionName);
 }