示例#1
0
 public Task UpdateAsync(
     CustomerSource source,
     Dictionary <string, string> headers = default,
     CancellationToken ct = default)
 {
     return(_factory.PatchAsync(_host + "/Customers/Sources/v1/Update", null, source, headers, ct));
 }
        public async Task CanRequestCardPayment()
        {
            var firstCardPayment         = TestHelper.CreateCardPaymentRequest();
            var firstCardPaymentResponse = await _api.Payments.RequestAsync(firstCardPayment);

            var customerSource         = new CustomerSource(firstCardPayment.Customer.Id, firstCardPayment.Customer.Email);
            var customerPaymentRequest = new PaymentRequest <CustomerSource>(
                customerSource,
                Currency.GBP,
                100
                )
            {
                Capture = false,
            };

            PaymentResponse paymentResponse = await _api.Payments.RequestAsync(customerPaymentRequest);

            paymentResponse.Payment.ShouldNotBeNull();
            paymentResponse.Payment.Approved.ShouldBeTrue();
            paymentResponse.Payment.Id.ShouldNotBeNullOrEmpty();
            paymentResponse.Payment.Id.ShouldNotBe(firstCardPaymentResponse.Payment.Id);
            paymentResponse.Payment.ActionId.ShouldNotBeNullOrEmpty();
            paymentResponse.Payment.Amount.ShouldBe(customerPaymentRequest.Amount.Value);
            paymentResponse.Payment.Currency.ShouldBe(customerPaymentRequest.Currency);
            paymentResponse.Payment.Reference.ShouldBe(customerPaymentRequest.Reference);
            paymentResponse.Payment.Customer.ShouldNotBeNull();
            paymentResponse.Payment.Customer.Id.ShouldNotBeNullOrEmpty();
            paymentResponse.Payment.Customer.Email.ShouldNotBeNullOrEmpty();
            paymentResponse.Payment.Customer.Id.ShouldBe(firstCardPaymentResponse.Payment?.Customer?.Id);
            paymentResponse.Payment.Source.AsCard().ShouldNotBeNull();
            paymentResponse.Payment.Source.AsCard().Id.ShouldBe(firstCardPaymentResponse.Payment?.Source?.AsCard().Id);
            paymentResponse.Payment.CanCapture().ShouldBeTrue();
            paymentResponse.Payment.CanVoid().ShouldBeTrue();
        }
        public async Task <ActionResult <Guid> > Create(CustomerSource source, CancellationToken ct = default)
        {
            source.AccountId = _userContext.AccountId;

            var id = await _customerSourcesService.CreateAsync(_userContext.UserId, source, ct);

            return(Created(nameof(Get), id));
        }
示例#4
0
        private async void RemoveSourceAsync(CustomerSource customerSource)
        {
            var result = await StripeManager.Instance.DetachSourceFromCustomerAsync(customerSource.Id)
                         .ConfigureAwait(false);

            if (result)
            {
                await LoadDataAsync().ConfigureAwait(false);
            }
        }
示例#5
0
        public dynamic GetSource()
        {
            int              id     = Fun.Query("id", 0);
            CustomerBLL      c      = new CustomerBLL();
            C_CustomerSource s      = c.GetSource(id);
            CustomerSource   source = new CustomerSource();

            source.id   = s.source_id;
            source.name = s.source_name.Trim();
            return(source);
        }
        public static CustomerSourceChange CreateWithLog(this CustomerSource source, Guid userId, Action <CustomerSource> action)
        {
            action(source);

            return(new CustomerSourceChange
            {
                SourceId = source.Id,
                ChangerUserId = userId,
                CreateDateTime = DateTime.UtcNow,
                OldValueJson = string.Empty,
                NewValueJson = source.ToJsonString()
            });
        }
 public CustomerSourceBuilder(
     IDefaultRequestHeadersService defaultRequestHeadersService,
     ICustomerSourcesClient customerSourcesClient)
 {
     _customerSourcesClient        = customerSourcesClient;
     _defaultRequestHeadersService = defaultRequestHeadersService;
     _source = new CustomerSource
     {
         Id        = Guid.NewGuid(),
         Name      = "Test".WithGuid(),
         IsDeleted = false
     };
 }
        public async Task <ActionResult> Update(CustomerSource source, CancellationToken ct = default)
        {
            var oldSource = await _customerSourcesService.GetAsync(source.Id, true, ct);

            if (oldSource == null)
            {
                return(NotFound(source.Id));
            }

            return(await ActionIfAllowed(
                       () => _customerSourcesService.UpdateAsync(_userContext.UserId, oldSource, source, ct),
                       Roles.Customers,
                       oldSource.AccountId));
        }
        private void ReloadDataGrid()
        {
            var text = SearchTextBox.Text == DefaultText ? "" : SearchTextBox.Text;

            CustomerSource.Clear();
            var selectionId = CustomerDataGrid.SelectedIndex;

            foreach (var customer in Customer.GetCustomers(name: text))
            {
                CustomerSource.Add(customer);
            }
            CustomerDataGrid.SelectedIndex = CustomerDataGrid.Items.Count > selectionId
               ? selectionId
               : CustomerDataGrid.Items.Count - 1;
        }
示例#10
0
            public void BindHolder(CustomerSource item, bool isSelected)
            {
                _textView.Text = item.Id;
                _source        = WeakReferenceEx.Create(item);

                var card = item.AsCard();

                _textView.Text = $"{card.Brand} - ...{card.Last4}";

                var imageId = (int)Card.BrandResourceMap[card.Brand];

                _imageView.SetImageResource(imageId);

                _selectedImage.Visibility = isSelected ? ViewStates.Visible : ViewStates.Invisible;
            }
示例#11
0
        public async Task UpdateAsync(
            Guid userId,
            CustomerSource oldSource,
            CustomerSource newSource,
            CancellationToken ct)
        {
            var change = oldSource.UpdateWithLog(userId, x =>
            {
                x.Name           = newSource.Name;
                x.IsDeleted      = newSource.IsDeleted;
                x.ModifyDateTime = DateTime.UtcNow;
            });

            _storage.Update(oldSource);
            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);
        }
示例#12
0
        public async Task <Guid> CreateAsync(Guid userId, CustomerSource source, CancellationToken ct)
        {
            var newSource = new CustomerSource();
            var change    = newSource.CreateWithLog(userId, x =>
            {
                x.Id             = source.Id;
                x.AccountId      = source.AccountId;
                x.Name           = source.Name;
                x.IsDeleted      = source.IsDeleted;
                x.CreateDateTime = DateTime.UtcNow;
            });

            var entry = await _storage.AddAsync(newSource, ct);

            await _storage.AddAsync(change, ct);

            await _storage.SaveChangesAsync(ct);

            return(entry.Entity.Id);
        }
示例#13
0
        public async Task WhenCreate_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var status = new CustomerSource
            {
                Id        = Guid.NewGuid(),
                Name      = "Test".WithGuid(),
                IsDeleted = false
            };

            var createdSourceId = await _customerSourcesClient.CreateAsync(status, headers);

            var createdSource = await _customerSourcesClient.GetAsync(createdSourceId, headers);

            Assert.NotNull(createdSource);
            Assert.Equal(createdSourceId, createdSource.Id);
            Assert.Equal(status.Name, createdSource.Name);
            Assert.Equal(status.IsDeleted, createdSource.IsDeleted);
            Assert.True(createdSource.CreateDateTime.IsMoreThanMinValue());
        }
示例#14
0
 private void OnSourceSelected(CustomerSource customerSource)
 {
     _selectedIndex = _items.IndexOf(customerSource);
     NotifyDataSetChanged();
 }
示例#15
0
        public static string setVisitData(List <dynamic> listCustomer, List <dynamic> listSoftware, int count)
        {
            CustomerAnalyzeModel cam = new CustomerAnalyzeModel();

            if (listCustomer != null && listSoftware != null && listCustomer.Count > 0 && listSoftware.Count > 0)
            {
                foreach (dynamic dr in listCustomer)
                {
                    CustomerSource cs   = new CustomerSource();
                    string         type = dr.a_customerSourceType.ToString();

                    switch (type)
                    {
                    case "1":
                        cs.sourceType = "朋友介绍";
                        break;

                    case "2":
                        cs.sourceType = "百度搜索";
                        break;

                    case "3":
                        cs.sourceType = "其他";
                        break;

                    default:
                        cs.sourceType = "";
                        break;
                    }
                    cs.sourceCount = Convert.ToInt32(dr.Cnt);
                    cam.csList.Add(cs);
                }
                //渠道
                foreach (dynamic dr in listSoftware)
                {
                    OtherSoftware os   = new OtherSoftware();
                    string        type = dr.a_OtherSoftwareType.ToString();

                    switch (type)
                    {
                    case "1":
                        os.softwareType = "使用过其他软件";
                        break;

                    case "2":
                        os.softwareType = "未使用过其他软件";
                        break;

                    default:
                        os.softwareType = "";
                        break;
                    }
                    os.softwareCount = Convert.ToInt32(dr.Cnt);
                    cam.osList.Add(os);
                }

                cam.unrecordNum = count;

                return(CommonLib.Helper.JsonSerializeObject(cam));
            }
            else
            {
                return("[]");
            }
        }