public CustomerPersonalInfo UpdateCustomerPersonalInfo(UpdateCustomerPersonalInfoDTO updatedCustomerPersonalInfo, int id) { using (var db = new SqlConnection(_connectionString)) { var sql = @"Update [CustomerPersonalInfo] SET [FirstName] = @firstName ,[LastName] = @lastName ,[CustomerEmail] = @customerEmail output inserted.* where id = @id"; updatedCustomerPersonalInfo.Id = id; var customer = db.QueryFirstOrDefault <CustomerPersonalInfo>(sql, updatedCustomerPersonalInfo); return(customer); } }
public IActionResult UpdateCustomerPersonalInfo(UpdateCustomerPersonalInfoDTO updatedCustomerPersonalInfoDTO, int id) { var repo = new CustomerPersonalInfoRepository(); var updatedCustomerPersonalInfo = new CustomerPersonalInfo { FirstName = updatedCustomerPersonalInfoDTO.FirstName, LastName = updatedCustomerPersonalInfoDTO.LastName, CustomerEmail = updatedCustomerPersonalInfoDTO.CustomerEmail, }; var customerPersonalInfoThatGotUpdated = repo.UpdateCustomerPersonalInfo(updatedCustomerPersonalInfoDTO, id); if (customerPersonalInfoThatGotUpdated == null) { return(BadRequest("Could not update trainer")); } return(Ok(customerPersonalInfoThatGotUpdated)); }