public HttpResponseMessage PostEmployee(Employee employee) { if (ModelState.IsValid) { employeeRepository.Insert(employee); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, employee); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
public EmployeeCourse(Employee employee) { EmployeeId = employee.EmployeeId; Employee = employee; }
public HttpResponseMessage PutEmployee(int id, Employee employee) { try { Logger.Info("Updating Employee"); if (id != employee.EmployeeId) { return Request.CreateResponse(HttpStatusCode.BadRequest); } var emp = (Employee) employee; employeeRepository.Update(x=>x.EmployeeId==emp.EmployeeId,emp); Logger.Info("Updated"); return Request.CreateResponse(HttpStatusCode.OK); } catch (Exception ex) { Logger.Error(ex.Message,ex); return Request.CreateResponse(HttpStatusCode.Conflict); } }