示例#1
0
        public IActionResult GetOrdersByCustomer(string Name)
        {
            if (Name is null)
            {
                return(BadRequest("Customer field was empty or null"));
            }
            var APICustomer = new CustomerApi(new Configuration {
                BasePath = "https://localhost:44368/"
            });
            var customers     = APICustomer.ApiCustomerGet();
            var foundCustomer = customers.FirstOrDefault(cust => cust.Name.Equals(Name));

            if (foundCustomer is not null)
            {
                var APIOrder = new OrderApi(new Configuration {
                    BasePath = "https://localhost:44368/"
                });
                var          orders         = APIOrder.ApiOrderGet();
                List <Order> customerOrders = orders.Where(
                    order => order.Customer.Id.Equals(foundCustomer.Id)).ToList();
                return(View(customerOrders));
            }

            ViewBag.ErrorMessage = "This user has no previous orders.";
            return(View("ViewCustomerOrders"));
        }
        public IActionResult CheckCustomerName(string Name)
        {
            if (Name is null)
            {
                return(BadRequest("Customer field was empty or null"));
            }

            var sessionOrder = Utils.GetCurrentOrder(HttpContext.Session);                          //get current session
            var API          = new CustomerApi(new Configuration {
                BasePath = "https://localhost:44368/"
            });
            var customers     = API.ApiCustomerGet();                                      //grabs list of customers from DB
            var foundCustomer = customers.FirstOrDefault(cust => cust.Name.Equals(Name));  //checks if the customer name entered already exists in the DB

            if (foundCustomer is not null)                                                 //if the user exists in the DB, apply the ID found in the DB
            {
                sessionOrder.Customer = foundCustomer;
            }
            else
            {
                sessionOrder.Customer = new Customer(Name);
            }

            //sessionOrder.Customer.Name = Name;                                             //saves customer in the session data
            Utils.SaveOrder(HttpContext.Session, sessionOrder);                                     //saves the session data for use on another page

            return(RedirectToAction("SelectStore", "FEStore"));
        }
示例#3
0
 public CreateOrderAction(OrderApi orderApi, CustomerApi customerApi, ProductApi productApi, OrderLineApi orderLineApi)
 {
     _orderApi     = orderApi;
     _customerApi  = customerApi;
     _productApi   = productApi;
     _orderLineApi = orderLineApi;
 }
示例#4
0
        public void TestToCreateTwoCustomerAndChangeOneOfThem()
        {
            var aggregateStore = new InMemoryAggregateStore();
            var modelsStore    = new InMemoryReadModel();

            var reciever = new CustomerCommandsHandler(aggregateStore);
            var queries  = new CustomerQueriesHandler(modelsStore);

            var api = new CustomerApi(reciever, queries);

            var id1 = Guid.NewGuid();
            var id2 = Guid.NewGuid();

            api.Process(new CreateCustomer {
                Id = id1, Name = "Customer One"
            });
            api.Process(new CreateCustomer {
                Id = id2, Name = "Customer Two"
            });

            api.Process(new ChangeCustomer {
                Id = id2, Name = "Customer Two Changed"
            });

            var customer = api.Retrieve <CustomerModel>(new GetCustomer
            {
                Id = id2
            });

            customer.Name.ShouldBeEquivalentTo("Customer Two Changed");
        }
示例#5
0
        /// <summary>
        /// Get customer data
        /// </summary>
        /// <param name="siteUserGuid">siteuserGuid</param>
        /// <returns>statuscode and Customer data</returns>
        public ApiResponse <Customer> GetCustomer(int siteUserGuid)
        {
            var myClassname = MethodBase.GetCurrentMethod().Name;
            var config      = this.GetDefaultApiConfiguration();
            var api         = new CustomerApi(config);

            for (var i = 0; i <= MaxNoOfRetries; i++)
            {
                try
                {
                    var res = api.GetCustomerWithHttpInfo(siteUserGuid.ToString());
                    if (res.StatusCode != (int)HttpStatusCode.OK)
                    {
                        this._log.Error($"Unexpected answer from reepay. {myClassname} Errorcode {res.StatusCode}");
                    }

                    return(res);
                }
                catch (ApiException apiException)
                {
                    this._log.Error($"{myClassname} {apiException.ErrorCode} {apiException.ErrorContent}");
                    return(new ApiResponse <Customer>(apiException.ErrorCode, null, null));
                }
                catch (Exception) when(i < MaxNoOfRetries)
                {
                    this._log.Debug($"{myClassname} retry attempt {i}");
                }
            }

            return(new ApiResponse <Customer>((int)HttpStatusCode.InternalServerError, null, null));
        }
示例#6
0
        public static TmsV2CustomersResponse Run()
        {
            string customerTokenId          = "AB695DA801DD1BB6E05341588E0A3BDC";
            string defaultShippingAddressId = "AB6A54B97C00FCB6E05341588E0A3935";
            Tmsv2customersDefaultShippingAddress defaultShippingAddress = new Tmsv2customersDefaultShippingAddress(
                Id: defaultShippingAddressId
                );

            var requestObj = new PatchCustomerRequest(
                DefaultShippingAddress: defaultShippingAddress
                );

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new CustomerApi(clientConfig);
                TmsV2CustomersResponse result = apiInstance.PatchCustomer(customerTokenId, requestObj);
                Console.WriteLine(result);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
                return(null);
            }
        }
示例#7
0
        /// <summary>
        /// Create customer in ReePay
        /// </summary>
        /// <param name="handle">Customer id, blank for auto generate</param>
        /// <param name="email"> customer email</param>
        /// <param name="firstName">custoemer firstname</param>
        /// <param name="lastname">customer last name</param>
        /// <param name="address">customer address</param>
        /// <param name="address2">customer address2</param>
        /// <param name="city">customer city</param>
        /// <param name="postalCode">customer postal code</param>
        /// <param name="country">customer country</param>
        /// <param name="phone">customer phone</param>
        /// <param name="company">customer company</param>
        /// <param name="vat">customer vat</param>
        /// <returns>statuscode and customer data</returns>
        public ApiResponse <Customer> CreateCustomer(string handle, string email, string firstName, string lastname, string address, string address2, string city,
                                                     string postalCode, string country, string phone, string company, string vat)
        {
            var myClassname    = MethodBase.GetCurrentMethod().Name;
            var generateHandle = string.IsNullOrEmpty(handle);
            var config         = this.GetDefaultApiConfiguration();
            var api            = new CustomerApi(config);
            var newCustomer    = new CreateCustomer(email, address, address2, city, country, phone, company, vat, handle, this._reepayTestFlag, firstName, lastname, postalCode, generateHandle);

            for (var i = 0; i <= MaxNoOfRetries; i++)
            {
                try
                {
                    var apiResponse = api.CreateCustomerJsonWithHttpInfo(newCustomer);
                    return(apiResponse);
                }
                catch (ApiException apiException)
                {
                    this._log.Error($"{myClassname} {apiException.ErrorCode} {apiException.ErrorContent}");
                    return(new ApiResponse <Customer>(apiException.ErrorCode, null, null));
                }
                catch (Exception) when(i < MaxNoOfRetries)
                {
                    this._log.Debug($"{myClassname} retry attempt {i}");
                }
            }

            return(new ApiResponse <Customer>((int)HttpStatusCode.InternalServerError, null, null));
        }
        public async void DeleteCustomerAddress_OK()
        {
            //Arrange
            var mockLogger             = new Mock <ILogger <CustomerApi> >();
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Post(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            });
            var baseAddress = "BaseAddress";

            var sut = new CustomerApi(
                mockLogger.Object,
                mockHttpRequestFactory.Object,
                baseAddress
                );

            //Act
            await sut.DeleteCustomerAddressAsync(new DeleteCustomerAddressRequest
            {
                AccountNumber = "AW00000001",
                AddressType   = "Home"
            }
                                                 );

            //Assert
            mockHttpRequestFactory.Verify(x => x.Post(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()));
        }
        public async void AddCustomerContactInfo_OK()
        {
            //Arrange
            var mockLogger             = new Mock <ILogger <CustomerApi> >();
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Post(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            });
            var baseAddress = "BaseAddress";

            var sut = new CustomerApi(
                mockLogger.Object,
                mockHttpRequestFactory.Object,
                baseAddress
                );

            //Act
            await sut.AddCustomerContactInfoAsync(new AddCustomerContactInfoRequest
            {
                AccountNumber       = "1",
                CustomerContactInfo = new Core.Abstractions.Api.CustomerApi.AddCustomerContactInfo.CustomerContactInfo
                {
                    Channel = Core.Abstractions.Api.CustomerApi.AddCustomerContactInfo.Channel.Email,
                    Value   = "*****@*****.**"
                }
            }
                                                  );

            //Assert
            mockHttpRequestFactory.Verify(x => x.Post(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()));
        }
        public async void UpdateCustomer_Person_OK()
        {
            //Arrange
            var mockLogger             = new Mock <ILogger <CustomerApi> >();
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Post(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            });
            var baseAddress = "BaseAddress";

            var sut = new CustomerApi(
                mockLogger.Object,
                mockHttpRequestFactory.Object,
                baseAddress
                );

            //Act
            await sut.UpdateCustomerAsync(new UpdateCustomerRequest
            {
                Customer = UpdateCustomer_Person()
            }
                                          );

            //Assert
            mockHttpRequestFactory.Verify(x => x.Post(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()));
        }
        public async void GetCustomer_Person_ReturnsCustomer()
        {
            //Arrange
            var mockLogger             = new Mock <ILogger <CustomerApi> >();
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Get(
                                             It.IsAny <string>(), It.IsAny <Dictionary <string, string> >(), It.IsAny <string>()
                                             )
                                         )
            .ReturnsAsync(new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new JsonContent(new GetCustomer.GetCustomerResponse
                {
                    Customer = GetCustomer_Person()
                })
            });

            var baseAddress = "BaseAddress";

            var sut = new CustomerApi(
                mockLogger.Object,
                mockHttpRequestFactory.Object,
                baseAddress
                );

            //Act
            var response = await sut.GetCustomerAsync(new GetCustomer.GetCustomerRequest());

            //Assert
            mockHttpRequestFactory.Verify(x => x.Get(It.IsAny <string>(), It.IsAny <Dictionary <string, string> >(), It.IsAny <string>()));

            response.Customer.AccountNumber.Should().Be("AW00011000");
        }
示例#12
0
        /// <summary>
        /// Check if customer has active subscription
        /// </summary>
        /// <param name="siteUserGuid">siteuserGuid</param>
        /// <returns>true, if customer has an active subscription</returns>
        public bool HasActiveSubscription(int siteUserGuid)
        {
            var myClassname = MethodBase.GetCurrentMethod().Name;
            var config      = this.GetDefaultApiConfiguration();
            var api         = new CustomerApi(config);

            for (var i = 0; i <= MaxNoOfRetries; i++)
            {
                try
                {
                    var res = api.GetCustomerWithHttpInfo(siteUserGuid.ToString());
                    return(res.Data.ActiveSubscriptions > 0);
                }
                catch (ApiException apiException)
                {
                    this._log.Error($"{myClassname} {apiException.ErrorCode} {apiException.ErrorContent}");
                    return(false);
                }
                catch (Exception) when(i < MaxNoOfRetries)
                {
                    this._log.Debug($"{myClassname} retry attempt {i}");
                }
            }

            return(false);
        }
示例#13
0
        public void TestToRemoveACustomer()
        {
            var aggregateStore = new InMemoryAggregateStore();
            var modelsStore    = new InMemoryReadModel();

            var reciever = new CustomerCommandsHandler(aggregateStore);
            var queries  = new CustomerQueriesHandler(modelsStore);

            var api = new CustomerApi(reciever, queries);

            var id = Guid.NewGuid();

            api.Process(new CreateCustomer {
                Id = id, Name = "Customer To Remove"
            });

            var customer = api.Retrieve <CustomerModel>(new GetCustomer
            {
                Id = id
            });

            customer.Should().NotBeNull();

            api.Process(new RemoveCustomer {
                Id = id
            });

            customer = api.Retrieve <CustomerModel>(new GetCustomer
            {
                Id = id
            });

            customer.Should().BeNull();
        }
示例#14
0
        public void TestToCreateAndChangeKundeViaApi()
        {
            var aggregateStore = new InMemoryAggregateStore();
            var queriesStore   = new InMemoryReadModel();

            var reciever = new CustomerCommandsHandler(aggregateStore);
            var queries  = new CustomerQueriesHandler(queriesStore);

            var api = new CustomerApi(reciever, queries);
            var id  = Guid.NewGuid();

            api.Process(new CreateCustomer {
                Id = id, Name = "My Customer"
            });
            api.Process(new ChangeCustomer {
                Id = id, Name = "New Name"
            });

            var customer = api.Retrieve <CustomerModel>(new GetCustomer
            {
                Id = id
            });

            customer.Name.ShouldBeEquivalentTo("New Name");
        }
        public async void UpdateCustomerContact_OK()
        {
            //Arrange
            var mockLogger             = new Mock <ILogger <CustomerApi> >();
            var mockHttpRequestFactory = new Mock <IHttpRequestFactory>();

            mockHttpRequestFactory.Setup(x => x.Post(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()))
            .ReturnsAsync(new HttpResponseMessage {
                StatusCode = HttpStatusCode.OK
            });
            var baseAddress = "BaseAddress";

            var sut = new CustomerApi(
                mockLogger.Object,
                mockHttpRequestFactory.Object,
                baseAddress
                );

            //Act
            await sut.UpdateCustomerContactAsync(new UpdateCustomerContactRequest
            {
                AccountNumber   = "AW00000001",
                CustomerContact = new UpdateCustomerContact_TB.CustomerContactBuilder().WithTestValues().Build()
            }
                                                 );

            //Assert
            mockHttpRequestFactory.Verify(x => x.Post(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <string>()));
        }
示例#16
0
        // GET: Customers/Details/5
        public ActionResult Details(int?id)
        {
            string tokenausar = System.Web.HttpContext.Current.Session["tokenuser"].ToString();

            RestClient  client  = new RestClient("http://localhost/CRM.API/api/Customers/" + id.ToString());
            RestRequest request = new RestRequest(Method.GET);

            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("content-type", "application/x-www-form-urlencoded");
            request.AddHeader("authorization", tokenausar);

            IRestResponse response    = client.Execute(request);
            string        strresponse = response.Content.ToString();

            strresponse = strresponse.Replace("[", "");
            strresponse = strresponse.Replace("]", "");

            CustomerApi responseCustomer   = JsonConvert.DeserializeObject <CustomerApi>(strresponse);
            var         configprofCustomer = FactoryProfile.CreateProfile <CustomerProfile>().GetProfile();

            /* https://dotnettutorials.net/lesson/automapper-in-c-sharp/ Ejemplo para usar el Mapper*/
            //Mapper mapper = new Mapper(CustomerProfile.GetProfile()); // Necesita el metodo static

            Mapper mapper    = new Mapper(configprofCustomer); // Necesita que el metodo no sea static
            var    responder = mapper.Map <CustomerApi, Customer>(responseCustomer);

            return(View(responder));
        }
示例#17
0
        public OrdersMonitoringSystem Resolve()
        {
            var customerApi  = new CustomerApi();
            var delivererApi = new DelivererApi();
            var system       = new OrdersMonitoringSystem(customerApi, delivererApi);

            return(system);
        }
示例#18
0
        public string CreateCustomer(DonationFormModel model)
        {
            Address address                   = new Address(model.StreetAddress1, model.StreetAddress2, null, model.City, null, null, null, model.State, null, null, model.ZipCode, null, model.FirstName, model.LastName, null);
            CreateCustomerRequest body        = new CreateCustomerRequest(model.FirstName, model.LastName, null, null, model.Email, address, model.Phone, null, null);
            CustomerApi           customerAPI = new CustomerApi();
            var response = customerAPI.CreateCustomer(squareAuthorization, body);

            return(response.Customer.Id);
        }
示例#19
0
        public static Customer GetCustomerByEmailCall(string Email)
        {
            const string simpleKey = "109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00";
            var          api       = new CustomerApi(simpleKey);
            string       expand    = null; // I'm only checking for existence, I don't need the expanded Customer object.
            var          response  = api.GetCustomerByEmail(Email, expand);

            return(response.Success == true ? response.Customer : null);
        }
示例#20
0
        public void ShouldReturnNoValuesForBadUpperBound()
        {
            ICustomerApi sut = new CustomerApi();

            var configDictionary = new Dictionary <int, string>();
            int upperBound       = 0;
            var actualValues     = sut.GetNumbers(upperBound, configDictionary);

            CollectionAssert.IsEmpty(actualValues);
        }
示例#21
0
 public ShopifyDataFeeder(
     InstanceContext connection,
     OrderApi orderApi,
     CustomerApi customerApi,
     IPushLogger logger)
 {
     _connection  = connection;
     _orderApi    = orderApi;
     _customerApi = customerApi;
     _logger      = logger;
 }
示例#22
0
        public void ShouldReturnNumberOfValuesEqualToUpperBound()
        {
            ICustomerApi sut = new CustomerApi();

            var configDictionary       = new Dictionary <int, string>();
            int expectedNumberOfValues = 100;

            int actualNumberOfValues = sut.GetNumbers(100, configDictionary).Count();

            Assert.That(actualNumberOfValues, Is.EqualTo(expectedNumberOfValues));
        }
示例#23
0
        public void ShouldPrintMultipleTriggerValuesForMatchingDivisors()
        {
            ICustomerApi sut = new CustomerApi();
            var          configDictionary = new Dictionary <int, string>()
            {
                { 3, "test1" },
                { 5, "test2" }
            };

            string expectedTriggerOutputValue = sut.GetNumbers(50, configDictionary).ToArray()[14];

            Assert.That(expectedTriggerOutputValue, Is.EqualTo("test1test2"));
        }
示例#24
0
        public static string GetEmailValidationToken(string Email, string Password)
        {
            const string simpleKey = "109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00";
            var          api       = new CustomerApi(simpleKey);

            EmailVerifyTokenRequest tokenRequest
                = new EmailVerifyTokenRequest {
                Email = Email, Password = Password
                };
            EmailVerifyTokenResponse response = api.GetEmailVerificationToken(tokenRequest);

            return(response.Token);
        }
示例#25
0
 public ShopifyJsonService(
     OrderApi orderApi,
     ProductApi productApi,
     InventoryApi inventoryApi,
     CustomerApi customerApi,
     ProcessPersistContext dataContext)
 {
     _orderApi     = orderApi;
     _productApi   = productApi;
     _inventoryApi = inventoryApi;
     _customerApi  = customerApi;
     _dataContext  = dataContext;
 }
示例#26
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (Globals.GetCurrentManagerUserId() <= 0)
            {
                context.Response.Write("{\"type\":\"error\",\"data\":\"请先登录\"}");
                context.Response.End();
            }
            int result = 0;

            int.TryParse(context.Request["id"].ToString(), out result);
            if (result > 0)
            {
                CustomerServiceInfo     customer       = CustomerServiceHelper.GetCustomer(result);
                CustomerServiceSettings masterSettings = CustomerServiceManager.GetMasterSettings(false);
                string tokenValue = TokenApi.GetTokenValue(masterSettings.AppId, masterSettings.AppSecret);
                if (!string.IsNullOrEmpty(tokenValue))
                {
                    string str2 = CustomerApi.DeleteCustomer(tokenValue, customer.unit, customer.userver);
                    if (!string.IsNullOrWhiteSpace(str2))
                    {
                        string jsonValue = Hishop.MeiQia.Api.Util.Common.GetJsonValue(str2, "errcode");
                        string str4      = Hishop.MeiQia.Api.Util.Common.GetJsonValue(str2, "errmsg");
                        if (jsonValue == "0")
                        {
                            if (CustomerServiceHelper.DeletCustomer(result))
                            {
                                context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                            }
                        }
                        else
                        {
                            context.Response.Write("{\"type\":\"error\",\"data\":\"" + str4 + "\"}");
                        }
                    }
                    else
                    {
                        context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                    }
                }
                else
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"获取access_token失败!\"}");
                }
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            wid = context.Session[DTKeys.SESSION_WEB_ID] as string;
            if (string.IsNullOrEmpty(wid))
            {
                return;
            }
            context.Response.ContentType = "text/plain";
            int result = 0;

            int.TryParse(context.Request["id"].ToString(), out result);
            if (result > 0)
            {
                CustomerServiceInfo     customer       = CustomerServiceHelper.GetCustomer(result);
                CustomerServiceSettings masterSettings = CustomerServiceManager.GetMasterSettings(false);
                string tokenValue = TokenApi.GetTokenValue(masterSettings.AppId, masterSettings.AppSecret);
                if (!string.IsNullOrEmpty(tokenValue))
                {
                    string str2 = CustomerApi.DeleteCustomer(tokenValue, customer.unit, customer.userver);
                    if (!string.IsNullOrWhiteSpace(str2))
                    {
                        string jsonValue = Common.GetJsonValue(str2, "errcode");
                        string str4      = Common.GetJsonValue(str2, "errmsg");
                        if (jsonValue == "0")
                        {
                            if (CustomerServiceHelper.DeletCustomer(result))
                            {
                                context.Response.Write("{\"type\":\"success\",\"data\":\"\"}");
                            }
                            else
                            {
                                context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                            }
                        }
                        else
                        {
                            context.Response.Write("{\"type\":\"error\",\"data\":\"" + str4 + "\"}");
                        }
                    }
                    else
                    {
                        context.Response.Write("{\"type\":\"error\",\"data\":\"删除客服失败!\"}");
                    }
                }
                else
                {
                    context.Response.Write("{\"type\":\"error\",\"data\":\"获取access_token失败!\"}");
                }
            }
        }
示例#28
0
        public static bool ValidateEmailValidationToken(string Token)
        {
            const string simpleKey = "109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00";
            var          api       = new CustomerApi(simpleKey);

            EmailVerifyTokenValidateRequest validateRequest
                = new EmailVerifyTokenValidateRequest()
                {
                Token = Token
                };
            EmailVerifyTokenValidateResponse response = api.ValidateEmailVerificationToken(validateRequest);

            return(response.Success ?? false);
        }
示例#29
0
        public void ShouldPrintTriggerValueForMatchingDivisors()
        {
            ICustomerApi sut = new CustomerApi();
            var          configDictionary = new Dictionary <int, string>()
            {
                { 3, "test" }
            };

            string[] outputFromSut = sut.GetNumbers(50, configDictionary).ToArray();
            string   expectedTriggerOutputValue1 = outputFromSut[2];
            string   expectedTriggerOutputValue2 = outputFromSut[8];

            Assert.That(expectedTriggerOutputValue1, Is.EqualTo("test"));
            Assert.That(expectedTriggerOutputValue2, Is.EqualTo("test"));
        }
示例#30
0
 public ShopifyCustomerGet(
     CustomerApi customerApi,
     ShopifyOrderRepository orderRepository,
     ShopifyBatchRepository batchRepository,
     SettingsRepository settingsRepository,
     JobMonitoringService jobMonitoringService,
     ShopifyJsonService shopifyJsonService)
 {
     _customerApi          = customerApi;
     _orderRepository      = orderRepository;
     _batchRepository      = batchRepository;
     _settingsRepository   = settingsRepository;
     _jobMonitoringService = jobMonitoringService;
     _shopifyJsonService   = shopifyJsonService;
 }
示例#31
0
    protected override void Page_Load(object sender, System.EventArgs e)
    {
        base.Page_Load(sender, e);

        if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce))
        {
            Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error"));
        }
        RegisterResources();
        AppPath = m_refContentApi.ApplicationPath;

        try
        {

            if (!Utilities.ValidateUserLogin())
            {
                return;
            }
            CommerceLibrary.CheckCommerceAdminAccess();

            System.Web.HttpCookie siteCookie = CommonApiBase.GetEcmCookie();
            Ektron.Cms.Commerce.CurrencyApi m_refCurrencyApi = new Ektron.Cms.Commerce.CurrencyApi();
            defaultCurrency = (new CurrencyApi()).GetItem(m_refContentApi.RequestInformationRef.CommerceSettings.DefaultCurrencyId);

            if (siteCookie["SiteCurrency"] != defaultCurrency.Id.ToString())
            {
                defaultCurrency.Id = Convert.ToInt32(siteCookie["SiteCurrency"]);
                defaultCurrency = m_refCurrencyApi.GetItem(defaultCurrency.Id);
            }

            if (!string.IsNullOrEmpty(Request.QueryString["customerid"]))
            {
                m_iCustomerId = Convert.ToInt64(Request.QueryString["customerid"]);
            }
            defaultCurrency = (new CurrencyApi()).GetItem(m_refContentApi.RequestInformationRef.CommerceSettings.DefaultCurrencyId);
            CustomerManager = new CustomerApi();
            AddressManager = new AddressApi();

            if (siteCookie["SiteCurrency"] != defaultCurrency.Id.ToString())
            {
                defaultCurrency.Id = Convert.ToInt32(siteCookie["SiteCurrency"]);
                defaultCurrency = m_refCurrencyApi.GetItem(defaultCurrency.Id);
            }

            switch (base.m_sPageAction)
            {
                case "addeditaddress":
                    RegionManager = new RegionApi();
                    CountryManager = new CountryApi();
                    if (Page.IsPostBack)
                    {
                        if (Request.Form[isCPostData.UniqueID] == "")
                        {
                            Process_ViewAddress();
                        }
                    }
                    else
                    {
                        Display_ViewAddress(true);
                    }
                    break;
                case "viewaddress":
                    RegionManager = new RegionApi();
                    CountryManager = new CountryApi();
                    Display_ViewAddress(false);
                    break;
                case "viewbasket":
                    Display_ViewBaskets(false);
                    break;
                case "view":
                    Display_View();
                    break;
                case "deleteaddress":
                    Process_AddressDelete();
                    break;
                case "deletebasket":
                    Process_BasketDelete();
                    break;
                default: // "viewall"
                    if (Page.IsPostBack == false)
                    {
                        Display_View_All();
                    }
                    break;
            }
            Util_SetLabels();
            Util_SetJS();
        }
        catch (Exception ex)
        {
            Utilities.ShowError(ex.Message);
        }
    }
示例#32
0
    private void DisplayUsers()
    {
        List<CustomerData> customerList = new List<CustomerData>();
        Ektron.Cms.Common.Criteria<CustomerProperty> CustomerCriteria = new Ektron.Cms.Common.Criteria<CustomerProperty>(CustomerProperty.UserName, Ektron.Cms.Common.EkEnumeration.OrderByDirection.Ascending);

        //CustomerCriteria.AddFilter(CustomerProperty.TotalOrders, CriteriaFilterOperator.GreaterThan, 0)
        //CustomerCriteria.AddFilter(CustomerProperty.TotalOrderValue, CriteriaFilterOperator.GreaterThan, 0)

        CustomerManager = new CustomerApi();

        m_strKeyWords = Request.Form["txtSearch"];

        m_strSelectedItem = Request.Form["searchlist"];

        switch (m_strSelectedItem)
        {

            //Case "-1 selected " ' All

            //    CustomerCriteria.AddFilter(CustomerProperty.FirstName, CriteriaFilterOperator.Contains, m_strKeyWords)

            //    CustomerCriteria.AddFilter(CustomerProperty.LastName, CriteriaFilterOperator.Contains, m_strKeyWords)

            //    CustomerCriteria.AddFilter(CustomerProperty.UserName, CriteriaFilterOperator.Contains, m_strKeyWords)

            //Case "-1" ' All

            //    CustomerCriteria.AddFilter(CustomerProperty.FirstName, CriteriaFilterOperator.Contains, m_strKeyWords)

            //    CustomerCriteria.AddFilter(CustomerProperty.LastName, CriteriaFilterOperator.Contains, m_strKeyWords)

            //    CustomerCriteria.AddFilter(CustomerProperty.UserName, CriteriaFilterOperator.Contains, m_strKeyWords)

            case "last_name": // Last Name

                CustomerCriteria.AddFilter(CustomerProperty.LastName, CriteriaFilterOperator.Contains, m_strKeyWords);
                break;

            case "first_name": // First Name

                CustomerCriteria.AddFilter(CustomerProperty.FirstName, CriteriaFilterOperator.Contains, m_strKeyWords);
                break;

            case "user_name": // User Name

                CustomerCriteria.AddFilter(CustomerProperty.UserName, CriteriaFilterOperator.Contains, m_strKeyWords);
                break;

        }

        customerList = CustomerManager.GetList(CustomerCriteria);

        ViewAllUsersToolBar();
        literal1.Text = "";
        if (customerList != null)
        {
            if (customerList.Count != 0)
            {
                if (customerList.Count > 0)
                {
                    dg_customers.DataSource = customerList;
                    dg_customers.DataBind();

                }
                else
                {
                    literal1.Text = "<br/><label style=\"color:#2E6E9E;\" id=\"lbl_noUsers\">" + this.GetMessage("lbl no users") + "</label>";
                }
            }
            else
            {
                literal1.Text = "<br/><label style=\"color:#2E6E9E;\" id=\"lbl_noUsers\">" + this.GetMessage("lbl no users") + "</label>";
            }
        }
        else
        {
            literal1.Text = "<br/><label style=\"color:#2E6E9E;\" id=\"lbl_noUsers\">" + this.GetMessage("lbl no users") + "</label>";
        }
        dg_customers.DataSource = customerList;
        dg_customers.DataBind();
    }