public ActionResult Index(ApiTestRequest request)
        {
            // Defaults
            request.BaseUri = ConfigurationManager.AppSettings["LitmosAPIBaseUri"].ToString();
            request.Source = "TESTHARNESS";

            return View(request);
        }
        public ActionResult ProcessRequest(ApiTestRequest request)
        {
            // Base uri
            string baseUri = ConfigurationManager.AppSettings["LitmosAPIBaseUri"].ToString();

            RESTResponse rs = new RESTResponse();
            RESTClient client = new RESTClient(baseUri, request.ApiKey, request.Source);
            RequestFactory factory = new RequestFactory(baseUri, request.ApiKey, request.Source);

            switch (request.RequestType)
            {
                case "USERS": // Get a List of Users
                    // Get
                    var listUsers = factory.ListUsers(Request.Form["Filter"]);

                    // Format Response
                    request.ResponseBody = GetUserList(listUsers);
                    break;

                case "USER": // Get a User
                    // Get
                    var singleUser = factory.GetUser(Request.Form["UserId"]);

                    // Format Response
                    request.ResponseBody = GetUser(singleUser);
                    break;

                case "CREATE_USER": // Create a User

                    UserProfile createUser = new UserProfile(Request.Form["UserName"], Request.Form["FirstName"], Request.Form["LastName"]);

                    // Create
                    var newUser = factory.CreateUser(createUser);

                    // Format Response
                    request.ResponseBody = GetUser(newUser);
                    break;

                case "UPDATE_USER": // Update a User

                    // Get User
                    var updateUser = factory.GetUser(Request.Form["UserId"]);

                    // Update User Properties
                    if (updateUser != null)
                    {
                        updateUser.Id = Request.Form["UserId"];
                        updateUser.FirstName = Request.Form["FirstName"];
                        updateUser.LastName = Request.Form["LastName"];

                        // Update 
                        updateUser = factory.UpdateUser(Request.Form["UserId"], updateUser);
                    }
                    break;

                case "TEAMS": // Get a List of Teams
                    request.ResponseBody = GetTeamList(factory.ListTeams(Request.Form["Filter"]));
                    break;

                case "SUBTEAMS": // Get a List of sub Teams
                    // Get
                    var subTeams = factory.ListTeams(Request.Form["TeamId"], Request.Form["Filter"]);

                    // Format Response
                    request.ResponseBody = GetTeamList(subTeams);
                    break;

                case "ADD_TEAMUSERS": // Get a List of Teams
                    
                    var users = new UserList();

                    users.Add(new UserProfilePartial(){
                        Id = Request.Form["UserId"]
                    });

                    var userTeamSuccess = factory.AddUsersToTeam(Request.Form["TeamId"], users);

                    // Format Response
                    request.ResponseBody = userTeamSuccess ? "Users added to team!" : "Users to team FAILED";
                    break;

                case "TEAMUSERS": // Get a List of Users
                    // Get
                    var listTeamUsers = factory.ListTeamUsers(Request.Form["TeamId"]);

                    // Format Response
                    request.ResponseBody = GetUserList(listTeamUsers);
                    break;

                case "PROMOTE_LEADER":
                    var promoteLeader = factory.PromoteTeamLeader(Request.Form["TeamId"], Request.Form["UserId"]);

                    // Format Response
                    request.ResponseBody = promoteLeader ? "Users promoted to team leader!" : "Users to team FAILED";
                    break;

                case "DEMOTE_LEADER":
                    var demoteTeamLeader = factory.DemoteTeamLeader(Request.Form["TeamId"], Request.Form["UserId"]);

                    // Format Response
                    request.ResponseBody = demoteTeamLeader ? "Users demoted from team leader!" : "Users to team FAILED";
                    break;

                case "COURSES": // Get a List of Courses
                    // Get
                    var listCourses = factory.ListCourses();

                    // Format Response
                    request.ResponseBody = GetCourseList(listCourses);
                    break;

                case "USER_COURSES": // Get a List of Courses
                    // Get
                    var listUserCourses = factory.ListUserCourses(Request.Form["UserId"]);

                    // Format Response
                    request.ResponseBody = GetUserCourseList(listUserCourses);
                    break;
            }


            if (rs != null)
            {
                request.ResponseStatusCode = rs.StatusCode;
                request.ResponseDescription = rs.StatusDescription;
            }

            return View("Index", request);
        }