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));
        }
Beispiel #2
0
 public IActionResult GetCustomers([FromQuery] string q, [FromQuery] string activeOrders)
 {
     if (q != null && activeOrders == null)
     {
         return(Ok(_storage.GetCustomerQuery(q)));
     }
     else if (q == null && activeOrders == "false")
     {
         return(Ok(_storage.GetInactiveCustomers()));
     }
     else
     {
         return(Ok(_storage.GetCustomers()));
     }
 }
Beispiel #3
0
        public void UpdateCustomer_ContactPersonProvided_UpdatesContactPerson()
        {
            var context = new AlvTimeDbContextBuilder()
                          .WithCustomers()
                          .CreateDbContext();

            var storage = new CustomerStorage(context);
            var creator = new CustomerCreator(storage);

            creator.UpdateCustomer(new CustomerDto
            {
                Id             = 1,
                InvoiceAddress = "Testveien 1"
            });

            var customer = storage.GetCustomers(new CustomerQuerySearch
            {
                Id = 1
            }).Single();

            Assert.Equal("Testveien 1", customer.InvoiceAddress);
        }