public IActionResult Get([FromQuery] int?id, string include, string q, bool?active)
        {
            if (id != null)
            {
                var customer = _customers.GetCustomerById(id);
                return(Ok(customer));
            }

            if (include != null)
            {
                if (include == "products")
                {
                    return(Ok(_customers.GetCustomersWithProducts()));
                }
                if (include == "payments")
                {
                    return(Ok(_customers.GetCustomersWithPayments()));
                }
            }

            if (q != null)
            {
                return(Ok(_customers.GetCustomersByTerm(q)));
            }

            if (active != null)
            {
                return(Ok(_customers.GetCustomersWithOrders(active)));
            }
            var allCustomers = _customers.GetCustomers();

            return(Ok(allCustomers));
        }
Example #2
0
 public IActionResult GetCustomerById(int id, [FromQuery] string include)
 {
     if (include == "products")
     {
         return(Ok(_storage.GetCustomerandProduct(id)));
     }
     else if (include == "payments")
     {
         return(Ok(_storage.GetCustomerandPayments(id)));
     }
     else
     {
         return(Ok(_storage.GetCustomerById(id)));
     }
 }
Example #3
0
 public IActionResult GetCustomerById(int CustomerId)
 {
     return(Ok(_storage.GetCustomerById(CustomerId)));
 }