Beispiel #1
0
        public async Task GetFindCorrect_correct()
        {
            var builder1    = ModelBuilder.BuildReplyCustomerBuilder("john");
            var builder2    = ModelBuilder.BuildReplyCustomerBuilder("manny");
            var listBuilder = new ModelListBuilder()
                              .Add(builder1)
                              .Add(builder2);

            var replyJson = listBuilder.BuildJson();

            var findCustomers = new FindCustomers()
            {
                Email = "*****@*****.**",
                Phone = "920920920",
            };
            var expectedQueryParams = new List <string> {
                "email", WebUtility.UrlEncode("*****@*****.**"), "phone", "920920920"
            };

            var ic = ConfigureIc("GET", "customers/find", replyJson, null, expectedQueryParams);

            var result = await ic.GetFindCustomersAsync(findCustomers);

            Assert.AreEqual(result.Count, 2);

            var model1 = builder1.BuildModel <Customer>(true);
            var model2 = builder2.BuildModel <Customer>(true);

            Assert.AreEqual(model1, result[0]);
            Assert.AreEqual(model2, result[1]);
        }
        /// <summary>
        /// Returns a list of custoemr that math the criteria
        /// </summary>
        /// <param name="findCustomers">the search criteria, fields are matched with AND</param>
        /// <returns>the list of found customers or empty list if no customer found</returns>
        public async Task <IList <Customer> > GetFindCustomersAsync(FindCustomers findCustomers)
        {
            _logger.LogDebug("Making request to find customers with the following info: {Model}", findCustomers);

            var ret = await MakeRequestAsync <List <Customer> >("GET", new[] { CustomersEndpoint, "find" }, findCustomers.SendableStringDictionary);

            _logger.LogDebug("Received find result customers: {Models}", ret.StringifyList());
            return(ret);
        }
Beispiel #3
0
        public object Get(FindCustomers request)
        {
            var query = documentSession.Query <CustomerAllPropertiesIndex.Result, CustomerAllPropertiesIndex>();

            if (!string.IsNullOrWhiteSpace(request.Name))
            {
                query = query.Search(c => c.Query, request.Name);
            }

            if (!string.IsNullOrWhiteSpace(request.Company))
            {
                query = query.Search(c => c.Query, request.Company);
            }

            if (!string.IsNullOrWhiteSpace(request.Email))
            {
                query = query.Search(c => c.Query, request.Email);
            }

            return(query
                   .OfType <Customer>()
                   .ToList());
        }
        public object Get(FindCustomers request)
        {
            var query = documentSession.Query<CustomerAllPropertiesIndex.Result, CustomerAllPropertiesIndex>();

            if (!string.IsNullOrWhiteSpace(request.Name))
                query = query.Search(c => c.Query, request.Name);

            if (!string.IsNullOrWhiteSpace(request.Company))
                query = query.Search(c => c.Query, request.Company);

            if (!string.IsNullOrWhiteSpace(request.Email))
                query = query.Search(c => c.Query, request.Email);

            return query
                .OfType<Customer>()
                .ToList();
        }