private static Message CreateResponseMessage() { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); Employee employee = new Employee("001", "Zhang San", "123456", "*****@*****.**"); response.Content = new ObjectContent<Employee>(employee, new JsonMediaTypeFormatter()); string httpMessageTypeName = "System.Web.Http.SelfHost.Channels.HttpMessage, System.Web.Http.SelfHost"; Type httpMessageType = Type.GetType(httpMessageTypeName); return (Message)Activator.CreateInstance(httpMessageType, new object[] { response }); }
public void Update(Employee employee, int Id) { Employee emp = employees.Where(x => x.EmployeeId.Equals(Id)).FirstOrDefault(); emp.EmployeeName = employee.EmployeeName; emp.ManagerId = employee.ManagerId; }
public void Add(Employee employee) { employees.Add(employee); }