public void Setup() { _dbSetUpHelper = new DatabaseSetUpHelper(); _context = _dbSetUpHelper.GetContext(); _httpContextHelper = new HttpContextHelper(); _paymentsRepository = new PaymentsRepository(_context); _userPaymentsRepository = new UserPaymentsRepository(_context); _flatRepository = new FlatRepository(_context); _userRepository = new UserRepository(_context); _mapperHelper = new MapperHelper(); var mapper = _mapperHelper.GetMapper(); var httpContext = _httpContextHelper.GetHttpContext(); var objClaim = _httpContextHelper.GetClaimsIdentity(); _paymentsController = new PaymentsController(_paymentsRepository, _userPaymentsRepository, _flatRepository, _userRepository, mapper) { ControllerContext = new ControllerContext { HttpContext = httpContext } }; httpContext.User = new ClaimsPrincipal(objClaim); }
public void Setup() { _dbSetUpHelper = new DatabaseSetUpHelper(); _context = _dbSetUpHelper.GetContext(); _paymentsRepository = new PaymentsRepository(_context); _userPaymentsRepository = new UserPaymentsRepository(_context); _flatRepository = new FlatRepository(_context); _userRepository = new UserRepository(_context); _mapperHelper = new MapperHelper(); var mapper = _mapperHelper.GetMapper(); DefaultHttpContext httpContext = new DefaultHttpContext(); GenericIdentity MyIdentity = new GenericIdentity("User"); ClaimsIdentity objClaim = new ClaimsIdentity(new List <Claim> { new Claim(ClaimTypes.NameIdentifier, "1") }); _paymentsController = new PaymentsController(_paymentsRepository, _userPaymentsRepository, _flatRepository, _userRepository, mapper) { ControllerContext = new ControllerContext() }; _paymentsController.ControllerContext.HttpContext = httpContext; httpContext.User = new ClaimsPrincipal(objClaim); }
private void SetProjectionListener(PaymentsRepository repository, IServiceCollection services) { var config = new RabbitMqConfig(); configuration.GetSection("RabbitMq").Bind(config); var logger = services.BuildServiceProvider().GetService <ILogger <RabbitMqPublisher> >(); var rabbitMq = new RabbitMqChannelFactory().CreateReadChannel <Models.Payment, string>(config, "PaymentsRead", logger); rabbitMq.Received += (sender, projection) => { if (projection.Upsert != null && projection.Upsert.Length > 0) { repository.Upsert(projection.Upsert); } if (projection.Upsert != null && projection.Upsert.Length == 0) { repository.Clear(); } if (projection.Remove != null) { repository.Remove(projection.Remove); } }; }
public static PaymentsRepository Create(PaymentDbContext context) { context.Database.EnsureCreated(); var paymentRepo = new PaymentsRepository(context); return(paymentRepo); }
protected override void OnStartup(StartupEventArgs e) { HibernatingRhinos.Profiler.Appender.EntityFramework.EntityFrameworkProfiler.Initialize(); base.OnStartup(e); //главный контекст MainContext = new MainEntititesContext(); //Стартовое окно выбора отеля var hotelsRepository = new HotelsRepository(MainContext); var startWindowViewModel = new StartWindowViewModel(hotelsRepository); var startWindow = new StartWindow() { DataContext = startWindowViewModel }; startWindow.Show(); //подписка на событие выбора отеля startWindowViewModel.StartButtonClicked += () => { MainContext.CurrentHotel = startWindowViewModel.SelectedHotel; //--Создание репозитеориев с данными var guestsRepository = new GuestsRepository(MainContext); var roomsRepository = new RoomsRepository(MainContext); var typesRepository = new TypeOfRoomsRepository(MainContext); var registrationRepository = new RegistrationRepository(MainContext); var registrationViewRepository = new RegistrationViewRepository(MainContext); var paymentsRepository = new PaymentsRepository(MainContext); var paymentsViewRepository = new PaymentsViewRepository(MainContext); var wishesRepository = new WishesRepository(MainContext); var discountsRepository = new DiscountsRepository(MainContext); var guestsDiscountsRepository = new GuestsDiscountsRepository(MainContext); var servicesRepository = new ServicesRepository(MainContext); var realizationRepository = new ServiceRealizationRepository(MainContext); //создание модели представления главного окна var mainviewmodel = new MainWindowViewModel(hotelsRepository, guestsRepository, roomsRepository, typesRepository, registrationViewRepository, registrationRepository, paymentsRepository, paymentsViewRepository, wishesRepository, discountsRepository, guestsDiscountsRepository, servicesRepository, realizationRepository); //создание представления главного окна var mainview = new MainWindow() { DataContext = mainviewmodel }; mainview.Show(); startWindowViewModel = null; startWindow.Close(); }; }
public PaymentsReadService(PaymentsRepository paymentsRepository, ILogger <PaymentsReadService> logger, Mapper mapper, TransactionsReadClient transactionsClient, LoansReadClient loansClient) { this.paymentsRepository = paymentsRepository; this.logger = logger; this.mapper = mapper; this.transactionsClient = transactionsClient; this.loansClient = loansClient; }
[TestInitialize] public override void TestInitialize() { base.TestInitialize(); repository = new PaymentsRepository(db); controller = "payments"; detailsViewCaption = "Payment"; editViewCaption = detailsViewCaption; }
public PaymentsWriteService(PaymentsRepository paymentsRepository, ILogger <PaymentsWriteService> logger, Mapper mapper, TransactionsWriteClient transactionsClient, LoansWriteClient loansClient, RabbitMqPublisher projectionChannel) { this.paymentsRepository = paymentsRepository; this.logger = logger; this.mapper = mapper; this.transactionsClient = transactionsClient; this.loansClient = loansClient; this.projectionChannel = projectionChannel; }
void ConfigureDlg() { dateperiodpicker.StartDate = DateTime.Today.AddDays(-1); dateperiodpicker.EndDate = DateTime.Today; rbtnYesterday.Active = true; SetControlsAccessibility(); rbtnLast3Days.Clicked += OnRbtnLast3DaysToggled; rbtnYesterday.Clicked += OnRbtnYesterdayToggled; rbtnCustomPeriod.Clicked += OnCustomPeriodChanged; dateperiodpicker.PeriodChangedByUser += OnCustomPeriodChanged; ySCmbShop.SetRenderTextFunc <string>(o => string.IsNullOrWhiteSpace(o) ? "{ нет названия }" : o); ySCmbShop.ItemsList = PaymentsRepository.GetAllShopsFromTinkoff(UoW); }
public async Task AddPaymentAsync_ShouldAddPaymentWithCorrectMappingToContext() { //Arrange var paymentRecord = GetPaymentRecordObject(); var expectedPayment = GetPaymentFromPaymentRecord(paymentRecord); var sut = new PaymentsRepository(_context, _mapper); //Act await sut.AddPaymentAsync(paymentRecord); //Assert _context.Payments.Should().ContainEquivalentOf(expectedPayment); }
public void Setup() { _dbSetUpHelper = new DatabaseSetUpHelper(); _serviceProvider = _dbSetUpHelper.GetServiceDependencyResolver(); _context = _dbSetUpHelper.GetContext(); _paymentsRepository = new PaymentsRepository(_context); _userPaymentsRepository = new UserPaymentsRepository(_context); _flatRepository = new FlatRepository(_context); _userRepository = new UserRepository(_context); // ISSUE: controller takes in IMapper, but no way of instantiating _paymentsController = new PaymentsController(_paymentsRepository, _userPaymentsRepository, _flatRepository, _userRepository, null); }
async Task <List <IBacsResult> > IAgencyPaymentService.GetAgencyPayments(DateTime startDate, DateTime endDate) { var paymentRepository = new PaymentsRepository(); var payments = paymentRepository.GetBetweenDates(startDate, endDate); if (!payments.Any()) { throw new InvalidOperationException(string.Format(NO_AGENCY_PAYMENTS_FORMAT, startDate, endDate)); } var agencies = await GetAgenciesForPayments(payments); return(BuildAgencyPayments(payments, agencies)); }
void CompleteAllocation() { var distributedPayments = PaymentsRepository.GetAllDistributedPayments(UoW); if (distributedPayments.Any()) { foreach (var payment in distributedPayments) { payment.Status = PaymentState.completed; UoW.Save(payment); } UoW.Commit(); } }
/// <summary> /// Проверка, что в БД уже нет такого платежа /// </summary> /// <returns><c>true</c>, если есть такой номер платёжа в БД, /// <c>false</c> если номер платежа не найден в БД</returns> /// <param name="payment">Платёж</param> bool IsPaymentUploadedAlready(PaymentByCardOnline payment) { if (otherPaymentsFromDB == null || !otherPaymentsFromDB.Any()) { using (var uow = UnitOfWorkFactory.CreateWithoutRoot()) { otherPaymentsFromDB = PaymentsRepository.GetPaymentsByTwoMonths(uow, payment.DateAndTime); } } return(otherPaymentsFromDB.Any( x => x.Number == payment.PaymentNr && x.Sum == payment.PaymentRUR && x.Date == payment.DateAndTime)); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddLogging(c => c.AddSerilog().AddFile("log.txt")); var repository = new PaymentsRepository(); services.AddGrpc(options => { options.Interceptors.Add <LoggingInterceptor>("PaymentsRead"); options.MaxReceiveMessageSize = 16 * 1024 * 1024; }); services.AddSingleton(CreateMapper()); services.AddSingleton(repository); CreateClients(services); SetProjectionListener(repository, services); }
Clients_Orders oClients_Orders; // Выделенные в списках объекты //Carts_Bouquets oCarts_Bouquets; // /// <summary> /// Загрузка окна, инициализация контроллеров, загрузка в listview данных и сброс управления. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void MetroWindow_Loaded(object sender, RoutedEventArgs e) { DBConnection oDBConnection = new DBConnection(); await oDBConnection.InitializeDatabase(); oClientsRepository = new ClientsRepository(oDBConnection); oOrdersRepository = new OrdersRepository(oDBConnection); oCartsRepository = new CartsRepository(oDBConnection); oBouquetsRepository = new BouquetsRepository(oDBConnection); oCardsRepository = new CardsRepository(oDBConnection); oPaymentsRepository = new PaymentsRepository(oDBConnection); conn = oDBConnection.GetAsyncConnection(); await Update_ListView_Orders(); Clear_Control(); }
public async Task GetPaymentAsync_WhenPaymentIdAndCompanyIdMatchInTheContext_ShouldReturnPayment() { //Arrange var expectedPaymentRecord = GetPaymentRecordObject(); var paymentInContext = GetPaymentFromPaymentRecord(expectedPaymentRecord); _context.Payments.Add(paymentInContext); _context.SaveChanges(); var sut = new PaymentsRepository(_context, _mapper); //Act var result = await sut.GetPaymentAsync(expectedPaymentRecord.Id, expectedPaymentRecord.CompanyId); //Assert result.Should().NotBeNull(); result.Should().BeEquivalentTo(expectedPaymentRecord); }
public async Task GetPaymentAsync_WhenPaymentIdAndCompanyIdDoNotMatchInTheContext_ShouldReturnNull() { //Arrange var paymentRecord = GetPaymentRecordObject(); var paymentInContext = GetPaymentFromPaymentRecord(paymentRecord); _context.Payments.Add(paymentInContext); _context.SaveChanges(); var requestedPaymentId = Guid.NewGuid(); var requestedCompanyId = Guid.NewGuid(); var sut = new PaymentsRepository(_context, _mapper); //Act var result = await sut.GetPaymentAsync(requestedPaymentId, requestedCompanyId); //Assert result.Should().BeNull(); }
public PaymentsService(PaymentsRepository paymentsRepository, ILogger <PaymentsService> logger, PublishingRouter publishingRouter) { this.paymentsRepository = paymentsRepository; this.logger = logger; this.publishingRouter = publishingRouter; }
public FinancialController(PaymentsRepository PaymentsRepo, DocumentsRepository DocumentsRepo) { _PaymentsRepo = PaymentsRepo; _DocumentsRepo = DocumentsRepo; }
public void Trigger(int id) { var payments = PaymentsRepository.FetchPayments(id); var highSpendingStatuses = DetermineHighSpending.Compute(payments); SendNotification.Send(highSpendingStatuses); }
private void ConfirmPaymentsButton_Click(object sender, EventArgs e) { { /****************************************************************************************** ** Get fields in values ** ******************************************************************************************/ // getting values in lientNumberPaymentsField var clientNumber = int.Parse(ClientNumberPaymentsField.Text); // getting values in PayAmountPaymentField var paymentSum = decimal.Parse(PayAmountPaymentField.Text); // getting values IdOfObligation field var numOfObligation = int.Parse(IdOfObligationPaymentField.Text); // getting values NameOfObligPaymentsField var nameOfObl = NameOfObligPaymentsField.Text; /****************************************************************************************** ** Create Repository ** ******************************************************************************************/ // Creating repository of client ClientRepository client = new ClientRepository(); // Creating repository of obligation ObligationsRepository obligation = new ObligationsRepository(); // Creating repository of payment PaymentsRepository payment = new PaymentsRepository(); /****************************************************************************************** ** Processing of obligation and user ** ******************************************************************************************/ // Get current obligation var currentObl = obligation.GetObligations().FirstOrDefault(o => o.obligation_number == numOfObligation); // Get current user var currentCli = client.GetClients().FirstOrDefault(c => c.client_serial_number == clientNumber); // Check if fields are empty if (ClientNumberPaymentsField.Text.Length == 0 || PayAmountPaymentField.Text.Length == 0 || IdOfObligationPaymentField.Text.Length == 0 || NameOfObligPaymentsField.Text.Length == 0) { MessageBox.Show("Не сте въвели някое от полетата"); } else { // Adding a payments currentObl.payments.Add(payment.AddPayments(new payments { amount_of_payment = paymentSum, date_of_payment = DateTime.Now.Date } )); // Checking if client exists it will add obligation if (currentCli?.Obligations.FirstOrDefault(o => o.obligation_number == numOfObligation) == null) { // Add obligation in the client currentCli.Obligations.Add( currentObl); } else { // getting obligation number as index var index = currentCli.Obligations.ToList().IndexOf( currentCli.Obligations.ToList().FirstOrDefault( o => o.obligation_number == numOfObligation)); // remove old obligation currentCli.Obligations.ToList().RemoveAt(index); // add new obligation currentCli.Obligations.ToList().Insert( index, currentObl); } } } }
public PaymentsResolver(PaymentsRepository repository) { _repository = repository; }
public AgencyPaymentService(IAgencyService agencyService, IAgencyPaymentBuilder agencyPaymentBuilder) { _paymentsRepository = new PaymentsRepository(); _agencyService = agencyService; _agencyPaymentBuilder = agencyPaymentBuilder; }
private Facade() { OrderFacade = new OrderRepository(); SellerFacade = new SellerRepository(); PaymentsFacade = new PaymentsRepository(); }