示例#1
0
        public void TestAddCustomers()
        {
            //var cdl = new CustomerDataLayer((MyDbContext)dbContext);
            using (var context = new MyDbContext(dbContext))
            {
                var service = new CustomerDataLayer(context);

                Customer cust = new Customer();
                cust.CustomerID = 1;
                cust.FirstName  = "Praj";
                cust.LastName   = "Man";
                cust.DOB        = DateTime.Now;

                int ret = service.addCustomer(cust);

                Assert.Equal(1, ret);
            }
        }
示例#2
0
 public IActionResult Post([FromBody] Customer customer)
 {
     try
     {
         int ret = custDataLayer.addCustomer(customer);
         if (ret != -1)
         {
             return(Created("Get", customer));
         }
         else
         {
             return(NotFound("Customer was already present"));
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }