本文整理汇总了C#中HttpClient.UploadData方法的典型用法代码示例。如果您正苦于以下问题:C# HttpClient.UploadData方法的具体用法?C# HttpClient.UploadData怎么用?C# HttpClient.UploadData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpClient
的用法示例。
在下文中一共展示了HttpClient.UploadData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddRemarkToEmployeeTest
public void AddRemarkToEmployeeTest()
{
// add remark to employee
var employee = new Employee() { FirstName = "Jane", LastName = "Doe", Email = "[email protected]", JoiningDate = DateTime.UtcNow };
var client = new HttpClient();
var createdEmployee = client.UploadData<Employee, Employee>(EmployeeManagementServiceUrl + "employee", employee);
Assert.IsNotNull(createdEmployee);
Assert.IsTrue(string.IsNullOrWhiteSpace(createdEmployee.Id) == false);
var remark = new Remark() { Text = "Remark1" , CreateTimeStamp = DateTime.UtcNow};
var createdRemark = client.UploadData<Remark, Remark>(EmployeeManagementServiceUrl + "employee/"+ createdEmployee.Id + "/remark", remark);
Assert.IsNotNull(createdRemark);
Assert.IsTrue(createdRemark.CreateTimeStamp > DateTime.MinValue);
}
示例2: Add
public Status Add(int employeeId,Remark remark)
{
HttpClient client = new HttpClient();
var empRespone = client.UploadData<Remark, RemarkResponse>(_emsUri + "/employee/" + employeeId + "/remark", remark);
return empRespone.Status;
}
示例3: Add
public Status Add(int employeeId, Remark remark)
{
string emsUri = ConfigurationManager.AppSettings["EMSUri"];
HttpClient client = new HttpClient();
var empRespone = client.UploadData<Remark, RemarkResponse>(emsUri + "/employee/" + employeeId + "/remark", remark);
return empRespone.Status;
}
示例4: CreateEmployeeTest
public void CreateEmployeeTest()
{
if (!IsEnabled(TestContext)) return;
// Crate employee
var client = new HttpClient();
var createdEmployee = client.UploadData<Employee, Employee>(EmployeeManagementServiceUrl + "employee", DataAdapter.GetEmployee(TestContext));
Assert.IsNotNull(createdEmployee);
Assert.IsTrue(string.IsNullOrWhiteSpace(createdEmployee.Id) == false);
}
示例5: CreateEmployee
public Status CreateEmployee(Employee employee)
{
string EmployeeManagementServiceUrl = ConfigurationManager.AppSettings["EMSUri"];
var client = new HttpClient();
var createdEmployee = client.UploadData<Employee, EmployeeResponse>(EmployeeManagementServiceUrl + "/employee", employee);
if (createdEmployee.Status.StatusCode.Equals("200"))
{
return (createdEmployee.Status);
}
else
return null;
}
示例6: GetEmployeeByIdTest
public void GetEmployeeByIdTest()
{
// add remark to employee
var employee = new Employee() { FirstName = "Jane", LastName = "Doe", Email = "[email protected]", JoiningDate = DateTime.UtcNow };
var client = new HttpClient();
var createdEmployee = client.UploadData<Employee, Employee>(EmployeeManagementServiceUrl + "employee", employee);
Assert.IsNotNull(createdEmployee);
Assert.IsTrue(string.IsNullOrWhiteSpace(createdEmployee.Id) == false);
var getEmployee = client.GetData<Employee>(EmployeeServiceUrl + "employee/" + createdEmployee.Id);
Assert.IsNotNull(getEmployee);
Assert.IsTrue(string.IsNullOrWhiteSpace(getEmployee.Id) == false);
Assert.IsTrue(createdEmployee.Id == getEmployee.Id);
}
示例7: UpdatePassword
public Status UpdatePassword(ChangePasssword changePassword)
{
HttpClient client = new HttpClient();
var empResponse = client.UploadData<ChangePasssword, Result>(_emsUri + "/update", changePassword);
return empResponse.Status;
}
示例8: CreateInvalidEmployeeTest
public void CreateInvalidEmployeeTest()
{
var employee = new Employee();
var client = new HttpClient();
var createdEmployee = client.UploadData<Employee, Employee>(EmployeeManagementServiceUrl + "employee", employee);
}
示例9: AddRemarkToNonExistingEmployeeTest
public void AddRemarkToNonExistingEmployeeTest()
{
var client = new HttpClient();
var remark = new Remark() { Text = "Remark1" , CreateTimeStamp = DateTime.UtcNow};
var createdRemark = client.UploadData<Remark, Remark>(EmployeeManagementServiceUrl + "employee/testid/remark", remark);
}