コード例 #1
0
        /// <summary>
        /// Get a customer from the db by name, and register it with the data model assuming it doesn't already
        /// exist in the model.
        /// </summary>
        /// <param name="name">The name of the customer.</param>
        /// <returns>The customer created (or returned) by the Customers object in the datamodel, or null if that customer isn't
        /// in the Database.</returns>
        public Store.Customer GetCustomerByName(Name name)
        {
            Customer DBCustomer = GetDBCustomerByName(name);

            if (DBCustomer != null)
            {
                return(Db_StoreMapper.MapCustomerToStore(DBCustomer));
            }
            else
            {
                _logger.LogError($"Customer, {name}, is not in the DB.");
                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// Get a list of all customers in the model.
        /// </summary>
        /// <returns>An enumerable list of all customers. (Concretely a hashset) </returns>
        public IEnumerable <Store.Customer> GetCustomers()
        {
            HashSet <Store.Customer> customers = new HashSet <Store.Customer>();

            //convert and check if in model
            foreach (DataModel.Customer customer in _context.Customers.Include(cust => cust.StoreLocationNavigation))
            {
                //customers.Add();
                Store.Customer nextcustomer = Db_StoreMapper.MapCustomerToStore(customer);

                if (nextcustomer != null)
                {
                    customers.Add(nextcustomer);
                }
            }

            //return list
            return(customers);
        }