示例#1
0
        static Guid CreateClass(Guid courseGuid, Guid programGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            IClassService cService = factory.CreateClassService();

            var _class = new Class();
            // the following are required fields.
            _class.Name = "This is test class";
            _class.CourseGuid = courseGuid;
            _class.ProgramGuid = programGuid;

            // the following are optional fields.
            _class.StartDate = null;
            _class.EndDate = null;

            Guid classGuid = cService.Create(_class);

            if (classGuid == Guid.Empty)
            {
                printError(cService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Class {0} was created.", _class.Name));
            }
            return classGuid;
        }
示例#2
0
        static void AddUsersToGroup()
        {
            ServiceFactory factory = new ServiceFactory();
            IGroupService gService = factory.CreateGroupService();

            string[] usernames = "student,student2".Split(',');
            bool success = gService.AddUsers("6573F24D-4D0C-48D9-95C4-5BCFDDE80159", usernames);

            if (!success) printError(gService.LastError);
            else
            {
                foreach (var item in gService.Data)
                    Console.WriteLine(item.Value);
            }
        }
示例#3
0
        static void AddTeacherToClass()
        {
            ServiceFactory factory = new ServiceFactory();
            IClassService cService = factory.CreateClassService();

            string classGuid = "d3a65d5b-2045-47db-a326-ab787a2fe371";

            List<string> teacherList = new List<string>()
            {
                "user_10",
                "user_11"
            };

            bool success = cService.AddTeachers(classGuid, teacherList);

            if (!success)
            {
                printError(cService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Teachers are added specified class {0}.", classGuid));
            }
        }
示例#4
0
        static void AddTeacherToCourse()
        {
            ServiceFactory factory = new ServiceFactory();
            ICourseService cService = factory.CreateCourseService();

            string courseGuid = "1bd0d136-14d8-4ece-886e-b2614fbc8953";

            List<string> teacherList = new List<string>()
            {
                "user_10",
                "user_11"
            };

            bool success = cService.AddTeachers(courseGuid, teacherList);

            if (!success)
            {
                printError(cService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Teachers are added specified class {0}.", courseGuid));
            }
        }
示例#5
0
        static void GetUser(string username)
        {
            ServiceFactory factory = new ServiceFactory();
            IUserService uService = factory.CreateUserService();

            User user = uService.Get(username);

            if (uService.LastError != null)
            {
                printError(uService.LastError);
            }
            else
            {
                string name = user.FirstName + " " + user.LastName;
                Console.WriteLine(string.Format("Name of user {0} is {1}.", user.UserName, name));
            }
        }
示例#6
0
        static void GetProgram(Guid organizationalUnitGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService();

            OrganizationalUnit organizationalUnit = ouService.Get(organizationalUnitGuid);

            if (ouService.LastError != null)
            {
                Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode);
                Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString);
            }
            else
            {
                Console.WriteLine(string.Format("Name of organizational unit is {0}.", organizationalUnit.Name));
            }
        }
示例#7
0
        static void CreateOrganization()
        {
            ServiceFactory factory = new ServiceFactory();
            IOrganizationService oService = factory.CreateOrganizationService();

            var organization = new Organization()
            {
                Name = "Test Organizasyonum",
                Url = "localhost",
                Culture = "tr-TR",
                AllowAdvertisement = true,
                /*User informations*/
                AdministratorUsername = "******",
                AdministratorPassword = "******",
                AdministratorEmail = "*****@*****.**",
                AdministratorFirstname = "Test",
                AdministratorLastname = "Account",
                AdministratorGender = "Male"
            };

            bool success = oService.Create(organization);

            if (success) Console.WriteLine(string.Format("OrganizationGuid: {0}", oService.OrganizationId));
            else printError(oService.LastError);
        }
示例#8
0
        static void UpdateUser(string username, string programGuid = "")
        {
            ServiceFactory factory = new ServiceFactory();
            IUserService uService = factory.CreateUserService();

            var user = new User();
            // the following are required fields.
            user.UserName = username;
            user.Password = "******";
            user.FirstName = "Sample";
            user.LastName = "User";
            user.Email = "*****@*****.**";//e-mail must be unique
            user.Types = UserType.User.GetHashCode();

            // the following are optional.
            user.MobilePhone = "+905327775544";
            user.Comment = "This user is created by Alms API.";
            user.Culture = "tr-TR";
            user.HomeTown = "My hometown";
            user.City = "Istanbul";
            user.Country = "Türkiye";
            user.Occupation = "Software Engineer";
            user.Gender = "Male"; // OR Female
            // website url is optional but if you set it, it must be a valid URL.
            user.WebsiteURL = "http://www.alms.com.tr";
            user.CitizenshipIdentifier = "2433452456";
            user.Title = "Dr.";
            user.BirthDate = DateTime.Now.AddYears(-35);
            user.ProgramGuids = "";

            user.CustomProperty1 = "Custom prop 1";
            user.CustomProperty2 = "Custom prop 2";
            user.CustomProperty3 = "Custom prop 3";
            user.CustomProperty4 = "Custom prop 4";
            user.CustomProperty5 = "Custom prop 5";
            user.CustomProperty6 = "Custom prop 6";
            user.CustomProperty7 = "Custom prop 7";
            user.CustomProperty8 = "Custom prop 8";
            user.CustomProperty9 = "Custom prop 9";
            user.CustomProperty10 = "Custom prop 10";
            user.CustomProperty11 = "Custom prop 11";
            user.CustomProperty12 = "Custom prop 12";
            user.CustomProperty13 = "Custom prop 13";
            user.CustomProperty14 = "Custom prop 14";
            user.CustomProperty15 = "Custom prop 15";
            user.CustomProperty16 = "Custom prop 16";
            user.CustomProperty17 = "Custom prop 17";
            user.CustomProperty18 = "Custom prop 18";
            user.CustomProperty19 = "Custom prop 19";
            user.CustomProperty20 = "Custom prop 20";

            bool success = uService.Update(user);

            if (!success)
            {
                printError(uService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("User {0} was updated.", user.UserName));
            }
        }
示例#9
0
        static void UpdateMasterCourse(Guid masterCourseGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            IMasterCourseService mcService = factory.CreateMasterCourseService();

            var masterCourse = new MasterCourse();
            // the following are required fields.
            masterCourse.MasterCourseGuid = masterCourseGuid;
            masterCourse.Name = "Test Master Course - Modified";
            masterCourse.Programs = null; //Programlarda değişiklik istenmiyorsa bu değer null geçilmeli.

            // the following are optional fields.
            masterCourse.Description = "Description";
            masterCourse.ShortDescription = "ShortDescription";
            masterCourse.Categories = new List<string>();
            masterCourse.Audiences = new List<string>();

            bool success = mcService.Update(masterCourse);

            if (!success)
            {
                printError(mcService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Name of master course {0} was updated to {1}.", masterCourse.MasterCourseGuid, masterCourse.Name));
            }
        }
示例#10
0
        static void SearchUsers(string keyword, int offset = 0, int limit = 100)
        {
            ServiceFactory factory = new ServiceFactory();
            IUserService uService = factory.CreateUserService();

            IEnumerable<User> users = uService.Search(keyword, true, offset, limit); // get users who contain User_ in their names, surnames, email addresses or usernames.

            if (uService.LastError != null)
            {
                printError(uService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Found {0} users.", users.Count()));
            }
        }
示例#11
0
        static void SearchMasterCourses(string keyword, int offset = 0, int limit = 100)
        {
            ServiceFactory factory = new ServiceFactory();
            IMasterCourseService mcService = factory.CreateMasterCourseService();

            IEnumerable<MasterCourse> masterCourses = mcService.Search(keyword, true, offset, limit); // get master course data by masterCourseGuid

            if (mcService.LastError != null)
            {
                printError(mcService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Master course count is {0}.", masterCourses.Count()));
            }
        }
示例#12
0
        static void DeleteUser(string username)
        {
            ServiceFactory factory = new ServiceFactory();
            IUserService uService = factory.CreateUserService();
            bool success = uService.Delete(username);

            if (!success)
            {
                printError(uService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("User {0} was deleted.", username));
            }
        }
示例#13
0
        static void DeleteProgram(Guid organizationalUnitGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService();

            bool success = ouService.Delete(organizationalUnitGuid);

            if (!success)
            {
                Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode);
                Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString);
            }
            else
            {
                Console.WriteLine(string.Format("Organizational Unit [{0}] was deleted.", organizationalUnitGuid));
            }
        }
示例#14
0
        static void DeleteMasterCourse(Guid masterCourseGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            IMasterCourseService mcService = factory.CreateMasterCourseService();
            bool success = mcService.Delete(masterCourseGuid);

            if (!success)
            {
                printError(mcService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Master course {0} was deleted.", masterCourseGuid));
            }
        }
示例#15
0
 static void DeleteCourse(Guid courseGuid)
 {
     ServiceFactory factory = new ServiceFactory();
     ICourseService cService = factory.CreateCourseService();
     bool success = cService.Delete(courseGuid);
     if (!success)
     {
         printError(cService.LastError);
     }
     else
     {
         Console.WriteLine(string.Format("Course {0} was deleted.", courseGuid));
     }
 }
示例#16
0
        static Guid CreateProgram()
        {
            ServiceFactory factory = new ServiceFactory();
            IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService();

            var program = new OrganizationalUnit();
            // the following are required fields.
            program.Name = "A sample program created by API";
            program.Abbreviation = "TPCBA";
            program.IsProgram = true;

            // the following are optional fields.
            Guid guid = ouService.Create(program);
            bool success = guid != Guid.Empty;

            if (!success)
            {
                Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode);
                Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString);
                return Guid.Empty;
            }
            else
            {
                Console.WriteLine(string.Format("Program {0} was created.", program.Name));
                return guid;
            }
        }
示例#17
0
        static void EnrollUsers(Guid classGuid, params string[] usernames)
        {
            ServiceFactory factory = new ServiceFactory();
            IUserService uService = factory.CreateUserService();

            bool success = uService.Enroll(classGuid, usernames);

            if (!success)
            {
                printError(uService.LastError);
            }
            else
            {
                Console.WriteLine("All users enrolled.");
            }
        }
示例#18
0
        static void SearchCourses(string keyword, int offset = 0, int limit = 100)
        {
            ServiceFactory factory = new ServiceFactory();
            ICourseService cService = factory.CreateCourseService();

            IEnumerable<Course> courses = cService.Search(keyword, true, offset, limit);

            if (cService.LastError != null)
            {
                printError(cService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Found {0} courses.", courses.Count()));
            }
        }
示例#19
0
        static bool ExpireLoginToken()
        {
            ServiceFactory factory = new ServiceFactory();
            IUserService uService = factory.CreateUserService();

            var username = "******";

            return uService.ExpireLoginToken(username);
        }
示例#20
0
        static void SearchProgram(string keyword, int offset = 0, int limit = 100)
        {
            ServiceFactory factory = new ServiceFactory();
            IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService();

            IEnumerable<OrganizationalUnit> organizationalUnitList = ouService.Search(keyword, true, true, offset, limit);

            if (ouService.LastError != null)
            {
                Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode);
                Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString);
            }
            else
            {
                Console.WriteLine(string.Format("Found {0} programs.", organizationalUnitList.Count()));
            }
        }
示例#21
0
        static void GetCourse(Guid courseGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            ICourseService cService = factory.CreateCourseService();

            Course course = cService.Get(courseGuid);

            if (cService.LastError != null)
            {
                printError(cService.LastError);
            }
            else
            {
                string name = course.Name;
                Console.WriteLine(string.Format("Name of course is {0}.", name));
            }
        }
示例#22
0
        static void UpdateCourse(Guid courseGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            ICourseService cService = factory.CreateCourseService();

            var course = new Course()
            {
                CourseGuid = courseGuid,
                Name = "Test Course Modified " + DateTime.Now.ToString("dd.MM.yyyy hh:mm:ss")
            };

            bool success = cService.Update(course);

            if (!success)
            {
                printError(cService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Name of course {0} was updated to {1}.", courseGuid, course.Name));
            }
        }
示例#23
0
        static Guid CreateCourse(Guid masterCourseGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            ICourseService cService = factory.CreateCourseService();

            var course = new Course()
            {
                Name = "Test Course",
                Description = "Test course description",
                CourseDefaultView = AlmsSdk.Domain.Enums.CourseViewType.Card,
                CourseAllowSelfEnrollment = false,
                Abbreviation = "TTC",
                MasterCourseGuid = masterCourseGuid
            };

            Guid courseGuid = cService.Create(course);

            if (courseGuid == Guid.Empty)
            {
                printError(cService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Course {0} was created.", courseGuid));
            }
            return courseGuid;
        }
示例#24
0
        static void UpdateProgram(Guid organizationalUnitGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            IOrganizationalUnitService ouService = factory.CreateOrganizationalUnitService();

            var oUnit = new OrganizationalUnit();
            // the following are required fields.
            oUnit.OrganizationalUnitGuid = new Guid(organizationalUnitGuid.ToString());
            oUnit.Name = "Updated Organization Unit";

            // the following are optional.

            bool success = ouService.Update(oUnit);

            if (!success)
            {
                Console.WriteLine("ErrorCode: " + ouService.LastError.ErrorCode);
                Console.WriteLine("ErrorMessage: " + ouService.LastError.ErrorCodeString);
            }
            else
            {
                Console.WriteLine(string.Format("User {0} was updated.", oUnit.Name));
            }
        }
示例#25
0
        static void GetMasterCourse(Guid masterCourseGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            IMasterCourseService mcService = factory.CreateMasterCourseService();

            MasterCourse masterCourse = mcService.Get(masterCourseGuid); // get master course data by masterCourseGuid

            if (mcService.LastError != null)
            {
                printError(mcService.LastError);
            }
            else
            {
                string name = masterCourse.Name;
                Console.WriteLine(string.Format("Name of master course is {0}.", masterCourse.Name));
            }
        }
示例#26
0
        static string GetLoginToken()
        {
            ServiceFactory factory = new ServiceFactory();
            IUserService uService = factory.CreateUserService();

            var username = "******";

            return uService.GetLoginToken(username);
        }
示例#27
0
        static Guid CreateMasterCourse(Guid organizationalUnitGuid)
        {
            ServiceFactory factory = new ServiceFactory();
            IMasterCourseService mcService = factory.CreateMasterCourseService();

            var masterCourse = new MasterCourse();
            // the following are required fields.
            masterCourse.MasterCourseGuid = Guid.Empty;
            masterCourse.Name = "Test Master Course";
            masterCourse.Programs.Add(organizationalUnitGuid);

            // the following are optional fields.
            masterCourse.Description = "master course description";
            masterCourse.ShortDescription = "ShortDescription";
            masterCourse.Categories = new List<string>();
            masterCourse.Audiences = new List<string>();

            var masterCourseGuid = mcService.Create(masterCourse);

            if (masterCourseGuid == Guid.Empty)
            {
                printError(mcService.LastError);
            }
            else
            {
                Console.WriteLine(string.Format("Master course {0} was created.", masterCourse.Name));
            }
            return masterCourseGuid;
        }