public IActionResult UpdateCustomer([FromBody] MvCustomerUpdate customerUpdate) { try { var updated = _customerService.UpdatePerson(customerUpdate); if (!updated) { return(BadRequest()); } return(Ok()); } catch (Exception e) { throw e; } }
public bool UpdatePerson(MvCustomerUpdate customerUpdate) { using (var connection = _dah.GetConnection()) { var jsonNew = JsonConvert.SerializeObject(customerUpdate); var command = connection.CreateCommand(); command.CommandType = CommandType.StoredProcedure; command.CommandText = "SpUpdateOrganizationTsk"; command.Parameters.Add("@json", SqlDbType.NChar).Value = jsonNew; command.CommandTimeout = _comdTimeout; int rows = command.ExecuteNonQuery(); if (rows > 0) { return(true); } return(false); } }
public bool UpdateCustomer(MvCustomerUpdate customer) { var jsonNew = JsonConvert.SerializeObject(customer); using (var conn = _dah.GetConnection()) { using (var cmd = new SqlCommand("SpOrganizationUpdateTsk", 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); } } }
public IActionResult UpdateCustomer([FromBody] MvCustomerUpdate customer) { if (!ModelState.IsValid) { return(BadRequest()); } try { var updated = _customerService.UpdateCustomer(customer); if (!updated) { return(BadRequest()); } return(Ok()); } catch (Exception) { throw; } }