예제 #1
0
 public IActionResult Search(string str)
 {
     try
     {
         var customer = custDataLayer.searchCustomer(str);
         if (customer != null)
         {
             return(Ok(customer));
         }
         else
         {
             return(NotFound("Customer with firstname or lastname as " + str + " was not found"));
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
예제 #2
0
        public void TestSearchCustomer(string str)
        {
            //var cdl = new CustomerDataLayer((MyDbContext)dbContext);
            using (var context = new MyDbContext(dbContext))
            {
                var service = new CustomerDataLayer(context);

                Customer temp = service.searchCustomer(str);
                Customer ret  = null;
                if (temp != null)
                {
                    ret = service.getCustomer(temp.CustomerID);
                }
                else
                {
                    ret = null;
                }

                Assert.Equal(temp, ret);
            }
        }