示例#1
0
        public static async Task <Employee.Core.Employee> AddEmployeeAsync()
        {
            Employee.Core.Employee employee = new Employee.Core.Employee
            {
                EmployeeId     = 5,
                FirstName      = "kumar",
                LastName       = "test",
                PostCode       = "CM72TE",
                City           = "Braintree",
                EmploymentType = EmploymentType.FullTime,
                Manager        = "Test",
                Department     = DepartmentType.Travel,
                UserID         = 1,
                LoginTime      = DateTime.Now.AddHours(-1)
            };

            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(employee),
                                                          Encoding.UTF8, "application/json");
                using (var response = await httpClient.PostAsync("http://localhost:58064/api/Employee", content))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    employee = JsonConvert.DeserializeObject <Employee.Core.Employee>(apiResponse);
                }
            }
            return(employee);
        }
 public ActionResult <Employee.Core.Employee> Add(Employee.Core.Employee employee)
 {
     return(Employee.Add(employee));
 }