public void GetEmployeeByID() { ProxyImplementation service = new ProxyImplementation(); ProxyEmployee employee = service.GetEmployeeByID(1); Xunit.Assert.NotNull(employee); Xunit.Assert.True(employee.Id == 1); }
public HttpResponseMessage CreateEmployee([FromBody] ProxyEmployee employee) { if (employee != null) { MyProxyService.CreateEmployee(employee); return(Request.CreateResponse <ProxyEmployee>(HttpStatusCode.Created, employee)); } else { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "The employee is null")); } }
public HttpResponseMessage CreateOrUpdateEmployee([FromBody] ProxyEmployee employee) { if (employee != null) { MyProxyService.CreateOrUpdate(employee); return(Request.CreateResponse(HttpStatusCode.OK, employee)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee Not Found")); } }
public HttpResponseMessage GetEmployeeByID(int id) { ProxyEmployee pe = MyProxyService.GetEmployeeByID(id); if (pe != null) { return(Request.CreateResponse <ProxyEmployee>(HttpStatusCode.OK, pe)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee Not Found")); } }
public HttpResponseMessage UpdateEmployee([FromUri] int id, [FromBody] ProxyEmployee employee) { //kalw thn get id na dw an yparxei ProxyEmployee proxy = MyProxyService.GetEmployeeByID(id); if (proxy != null && employee != null) { MyProxyService.UpdateEmployee(id, employee); return(Request.CreateResponse <ProxyEmployee>(HttpStatusCode.OK, employee)); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee Not Found")); } }
public HttpResponseMessage DeleteEmployee([FromUri] int id) { //ProxyEmployee proxy = MyProxyService.GetEmployeeByID(id); //deyteros tropos elegxoy ProxyEmployee request = MyProxyService.GetEmployees().Where(x => x.Id == id).FirstOrDefault(); if (request != null) { MyProxyService.DeleteEmployee(id); return(Request.CreateResponse(HttpStatusCode.OK, "Employee Succesfull Deleted")); } else { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Employee Not Found")); } }
public void CreateOrUpdate(ProxyEmployee employee) { var client = new RestClient("http://localhost:50428/"); var request = new RestRequest("api/employee/createorupdate", Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(new ProxyEmployee { Id = employee.Id, Name = employee.Name, Salary = employee.Salary, Job = employee.Job, Birthday = employee.Birthday }); client.Post(request); }
public void UpdateEmployee() { ProxyImplementation service = new ProxyImplementation(); ProxyEmployee employee = new ProxyEmployee() { Id = 1054, Name = "Dimitris Kosmas", Salary = 130000, Birthday = new DateTime(1998, 04, 30, 13, 14, 19), Job = ".net developer" }; service.UpdateEmployee(1054, employee); List <ProxyEmployee> proxylist = service.GetEmployees(); Xunit.Assert.True(proxylist.Exists(x => x.Id == 1054 && x.Name == "Dimitris Kosmas" && x.Salary == 130000 && x.Id == 1054)); }
public void UpdateEmployee(int employeeid, ProxyEmployee employee) { var client = new RestClient("http://localhost:50428/"); var request = new RestRequest("api/employee/updateEmployee/" + employeeid, Method.PUT); //request.RequestFormat = DataFormat.Json; request.AddJsonBody(employee); //request.AddBody(new ProxyEmployee //{ // Id = employee.Id, // Name = employee.Name, // Salary = employee.Salary, // Job = employee.Job, // Birthday = employee.Birthday //}); client.Put(request); }
public void CreateEmployee() { ProxyImplementation service = new ProxyImplementation(); ProxyEmployee employee = new ProxyEmployee() { Id = 1041, Name = "Dimitris K. Kosmas", Salary = 25000, Birthday = new DateTime(1998, 04, 30, 13, 14, 19), Job = "ProxyEmployee" }; service.CreateEmployee(employee); List <ProxyEmployee> proxylist = service.GetEmployees(); Xunit.Assert.True(proxylist.Exists(x => x.Name == "Dimitris K. Kosmas" && x.Salary == 25000)); }