예제 #1
0
 public IActionResult UpdateCustomer([FromBody] MvUpdateCustomer customer)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     try
     {
         var updated = _customerService.UpdateCustomer(customer);
         if (!updated)
         {
             return(BadRequest());
         }
         return(Ok());
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
        public bool UpdateCustomer(MvUpdateCustomer customer)
        {
            var jsonNew = JsonConvert.SerializeObject(customer);

            using (var conn = _dah.GetConnection())
            {
                using (var cmd = new SqlCommand("SpCustomerUpd", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@Json", SqlDbType.NChar).Value = jsonNew;
                    cmd.CommandTimeout = int.Parse(_commandTimeout);
                    int rows = cmd.ExecuteNonQuery();
                    if (rows > 0)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
        }