Example #1
0
        private async void Start()
        {
            var x = PressButton;

            MessageResult = "";
            if (PressButton == PROVEEDOR)
            {
                var list = await providerService.GetProviderName(SearchName);

                Providers.Clear();

                HasCoincidence = (list.Count > 0) ? true : false;
                foreach (var item in list)
                {
                    Providers.Add(new Provider()
                    {
                        Code = item.Code,
                        Name = item.Name
                    });
                }
            }
            else
            {
                var _list = new List <OrderTShirt>();
                _list.Add(new OrderTShirt()
                {
                    Code = SearchName
                });
                SearchOrder(_list);
            }
        }
Example #2
0
        public Task Handle(SMSReceived notification, CancellationToken cancellationToken)
        {
            try
            {
                Provider provider = _providerService.GetProviderName(notification.sms.Phone);

                if (provider == Provider.None)
                {
                    return(Task.FromCanceled(cancellationToken));
                }

                IPaymentService service = _providerService.ServiceFromProviderFactory(provider, notification.sms.Phone, notification.sms.Contents);

                if (service.IsDeposit())
                {
                    var payment = service.GeneratePayment();
                    //check if ReferencePaymentExists
                    //if it doesn't exist - we good!
                    //if it exists
                    //Ask service if IsSamePayment(old, current)
                    //discard current one, i.e. do nothing
                    //email manager to reconcile manually
                    //save!
                }

                return(Task.FromCanceled(cancellationToken));
            }
            catch (UnprocessablePayment e)
            {
                //log this as an exception
                //email manager
                return(Task.FromException(e));
            }
        }
        public async Task WhenInValidUkprn_ThenReturnEmptyString()
        {
            var mockClient = new Mock <IRoatpService>();

            mockClient.Setup(x => x.GetProvider(It.IsAny <long>())).Throws(new HttpRequestException());
            var sut    = new ProviderService(mockClient.Object);
            var actual = await sut.GetProviderName(1234);

            actual.Should().Be(string.Empty);
        }
        public async Task WhenValidUkprn_ThenReturnProviderName()
        {
            var mockClient   = new Mock <IRoatpService>();
            var expectedName = "Provider Name";

            mockClient.Setup(x => x.GetProvider(It.IsAny <long>())).ReturnsAsync(new Provider {
                Name = expectedName
            });
            var sut    = new ProviderService(mockClient.Object);
            var actual = await sut.GetProviderName(1234);

            actual.Should().Be(expectedName);
        }
Example #5
0
        public async Task Handle(SMSReceived notification, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Saving stuff");
            try
            {
                Provider provider = _providerService.GetProviderName(notification.sms.Phone);

                if (provider == Provider.None)
                {
                    return; //Task.FromCanceled(cancellationToken);
                }

                IPaymentService service = _providerService.ServiceFromProviderFactory(provider, notification.sms.Phone, notification.sms.Contents);

                if (service.IsDeposit())
                {
                    var payment = service.GeneratePayment();
                    //check if ReferencePaymentExists
                    //if it doesn't exist - we good!
                    //if it exists
                    //Ask service if IsSamePayment(old, current)
                    //discard current one, i.e. do nothing
                    //email manager to reconcile manually
                    //save!
                    var paymentJson = JsonConvert.SerializeObject(payment);
                    // _context.Payments.Add(payment);
                    // await _context.SaveChangesAsync(cancellationToken);
                    // _logger.LogInformation($"Payment Saved: {paymentJson}");
                }

                return;// Task.FromCanceled(cancellationToken);
            }
            catch (UnprocessablePayment e)
            {
                _logger.LogError("Could not save payment", e);
                return;// Task.FromException(e);
            }
        }