コード例 #1
0
        public void TestEditCustomer(int id)
        {
            //var cdl = new CustomerDataLayer((MyDbContext)dbContext);
            using (var context = new MyDbContext(dbContext))
            {
                var      service  = new CustomerDataLayer(context);
                int      response = 1;
                Customer cust     = new Customer();
                cust.CustomerID = id;
                cust.FirstName  = "Prajith";
                cust.LastName   = "Maniyan";
                cust.DOB        = DateTime.Now;

                Customer temp = service.getCustomer(id);
                if (temp == null)
                {
                    response = -1;
                }
                else
                {
                    response = 1;
                }

                int ret = service.editCustomer(cust);

                Assert.Equal(response, ret);
            }
        }
コード例 #2
0
 public IActionResult Put([FromBody] Customer customer)
 {
     try
     {
         int ret = custDataLayer.editCustomer(customer);
         if (ret != -1)
         {
             return(Created("Get", customer));
         }
         else
         {
             return(NotFound("Customer was not found"));
         }
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }