public HttpResponseMessage EmployeeOperations(EmployeeModel empDetails) { try { empDetails = empDetails.Operation == null ? new EmployeeModel() { EmpId = 0, EmpName = "", Gender = "", DateOfBirth = "", DateOfJoin = "", Salary = 0, Operation = "GET" } : empDetails; IEmployee instance = EmployeeFactory.GetInstance(empDetails); var result = instance.Process <object>(); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception ex) { var errorMessagError = new HttpError(ex.Message) { { "ErrorCode", 405 } }; throw new HttpResponseException(ControllerContext.Request.CreateErrorResponse (HttpStatusCode.MethodNotAllowed, errorMessagError)); } }