示例#1
0
        public void HasAnyParameters_WhenEmailGiven_True()
        {
            var query = new SearchCustomers
            {
                Email = "*****@*****.**",
            };

            Assert.True(query.HasAnyParameters());
        }
示例#2
0
        public void HasAnyParameters_WhenNameGiven_True()
        {
            var query = new SearchCustomers
            {
                Name = "value"
            };

            Assert.True(query.HasAnyParameters());
        }
示例#3
0
 public CustomerSearchModel()
 {
     Search  = new SearchCustomers();
     Results = new SearchCustomers.CustomerSearchResult[0];
 }
 public Customer customerSearchID(string id) => SearchCustomers.customerSearchID(_customers, id);
 public string customerSearchLastName(string lName) => SearchCustomers.customerSearchLastName(_customers, lName);
 public string customerSearchFirstName(string fName) => SearchCustomers.customerSearchFirstName(_customers, fName);
示例#7
0
 public SearchService(IOptions <SearchSettings> searchOptions)
 {
     this._searchSettings   = searchOptions.Value;
     this._searchCustomers  = new SearchCustomers(_searchSettings.ServiceName, _searchSettings.IndexName, _searchSettings.ApiKey);
     this._manageSearchData = new ManageSearchData(_searchSettings.ServiceName, _searchSettings.IndexName, _searchSettings.ApiKey);
 }
示例#8
0
        public static void makeOrder()
        {
            // get all of the customers
            List <Customer> customers = SqlDb.GetAllCustomers();

            Library.DataBase db = new Library.DataBase(customers);

            // Print a list of the customers
            db.printCustomers();
            Console.WriteLine("Enter a Customer ID");
            string customerId = Console.ReadLine();

            // select your customer
            Customer customer = SearchCustomers.customerSearchID(customers, customerId);

            // don'd continue unless the person actually put in a correct customer id.
            if (customer.isValid())
            {
                // get the store information
                uiPrintAllStores();
                Console.WriteLine("Choose a Store: ");

                int    StoreChoiceCheck = 0;
                string StoreChoice      = Console.ReadLine();
                Int32.TryParse(StoreChoice, out StoreChoiceCheck);
                Store store = SqlDb.GetInventory(StoreChoiceCheck);
                if (store.hasInventory())
                {
                    // add store to our database
                    db.AddStore(store);

                    // making order
                    Order newOrder = new Order(StoreChoiceCheck, customer.CustomerId);
                    store.printInventory();

                    Console.WriteLine("Starting order press (q) to quit");
                    string choice = "";
                    while (choice.ToLower() != "q")
                    {
                        Console.WriteLine("Choose a Product");
                        choice = Console.ReadLine();
                        if (choice != "q" && choice != "q")
                        {
                            int choiceCheck = 0;
                            int.TryParse(choice, out choiceCheck);
                            // if user actually inserts a number
                            if (choiceCheck != 0)
                            {
                                // using the only store in the database grab the product from the inventory
                                var item = db[0].getInventory(choiceCheck);


                                //give user a chance to escape one more time
                                string quantity = "";
                                if (quantity != "q" && choice != "q" && item.ProductID != 0)
                                {
                                    Console.WriteLine("Choose a quantity: ");
                                    quantity = Console.ReadLine();
                                    int quantityCheck = 0;
                                    int.TryParse(quantity, out quantityCheck);
                                    if (quantityCheck != 0)
                                    {
                                        newOrder.addItem(item, quantityCheck);
                                        Console.WriteLine("Your Total So Far is " + newOrder.Cost);
                                    }
                                    else
                                    {
                                        Console.WriteLine("Quanity Must be greater than 0");
                                    }
                                }
                            }
                        }

                        db.Stores[0].AddOrder(newOrder);
                    }
                    // if we have items in our order submit to database
                    if (newOrder.hasItems())
                    {
                        int TransactionNumber = SqlDb.AddCustomerOrder(db);
                        Console.WriteLine(newOrder.newOrderString(TransactionNumber));
                    }
                }
            }
        }
示例#9
0
        public async Task <IEnumerable <SearchCustomers.CustomerSearchResult> > Handle(SearchCustomers request, CancellationToken cancellationToken)
        {
            var predicate = context.Customers.AsNoTracking();

            if (!string.IsNullOrWhiteSpace(request?.Name))
            {
                predicate = predicate.Where(c => c.Name.Contains(request.Name));
            }

            if (!string.IsNullOrWhiteSpace(request?.Email))
            {
                predicate = predicate.Where(c => c.Email.Contains(request.Email));
            }

            // materialize the results immediately
            var results = await predicate.ToListAsync(cancellationToken);

            return(results.Select(mapper.Map <SearchCustomers.CustomerSearchResult>));
        }
示例#10
0
        public void HasAnyParameters_False()
        {
            var query = new SearchCustomers();

            Assert.False(query.HasAnyParameters());
        }