Esempio n. 1
0
        public Models.Enrollment.EnrollmentData EnrollUser(int OrgUnitID, int UserID, int RoleId)
        {
            m_valenceUserContext = m_valenceAppContext.CreateUserContext(m_userId, m_userKey, m_valenceHost);
            Models.Enrollment.EnrollmentData rtnValue = new Models.Enrollment.EnrollmentData();

            Models.Enrollment.CreateEnrollmentData model =
                new Models.Enrollment.CreateEnrollmentData(OrgUnitID, UserID, RoleId );

            var client = new RestClient("https://" + LMS_URL);
            var authenticator = new ValenceAuthenticator(m_valenceUserContext);

            var request = new RestRequest( USER_CREATE_ENROLLMENT, Method.POST);

            RestSharp.Parameter p = new Parameter ();
            p.Type = ParameterType.RequestBody;
            p.Name = "CreateEnrollmentData";
            p.Value = SimpleJson.SerializeObject(model);

            request.AddParameter(p);

            authenticator.Authenticate(client, request);
            var response = client.Execute (request);

            return null;
        }
Esempio n. 2
0
        public bool DeleteUser(int OrgUnitID, int UserID)
        {
            m_valenceUserContext = m_valenceAppContext.CreateUserContext(m_userId, m_userKey, m_valenceHost);
            Models.Enrollment.EnrollmentData rtnValue = new Models.Enrollment.EnrollmentData();

            var client = new RestClient("https://" + LMS_URL);
            var authenticator = new ValenceAuthenticator(m_valenceUserContext);

            string url = string.Format(USER_ENROLL_REMOVE, OrgUnitID.ToString(), UserID.ToString());
            var request = new RestRequest(url, Method.DELETE);

            authenticator.Authenticate(client, request);
            var response = client.Execute(request);

            return true;
        }