public string GetAccountPath(int AccountID, List <Biz.Model.Account> accounts) { string rtnValue = ""; int Parent = AccountID; try { do { Biz.Model.Account account = accounts.First(e => e.id == Parent); if (rtnValue.Length > 0) { rtnValue = account.name + "\\" + rtnValue; } else { rtnValue = account.name; } Parent = account.parent_account_id; } while (Parent > 0); } catch (System.Exception ee) { System.Console.WriteLine(ee.ToString()); } return(rtnValue); }
public List <Biz.Model.Admin> getAccountAdmins(Biz.Model.Account account, List <Biz.Model.Account> accounts) { List <Biz.Model.Admin> rtnValue = new List <Model.Admin>(); var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; RestClient client = new RestClient(WebcoursesUri); RestRequest request = new RestRequest(string.Format(cAdminList, account.id.ToString()), Method.GET); addAuth(ref request); var response = client.Execute(request); rtnValue.AddRange(JsonConvert.DeserializeObject <List <Biz.Model.Admin> >(response.Content, settings)); string link = NextLink(response); while (link.Length != 0) { request = new RestRequest(link.Substring(1, link.Length - 2).Substring(WebcoursesUri.Length + 1), Method.GET); addAuth(ref request); response = client.Execute(request); rtnValue.AddRange(JsonConvert.DeserializeObject <List <Biz.Model.Admin> >(response.Content, settings)); link = NextLink(response); } foreach (Biz.Model.Admin item in rtnValue) { item.account = account; try { item.Email = getProfile((item.user.id.ToString())).primary_email; item.account.parent_account_name = accounts.First(e => e.id == account.parent_account_id).name; item.account.account_path = GetAccountPath(item.account.id, accounts); } catch (System.Exception e) { } } return(rtnValue); }
public List <Biz.Model.EnrollmentReportActReport> getEnrollmentDetails(string accountID, string enrollment_term_id) { List <Biz.Model.EnrollmentReportActReport> rtnValue = new List <Model.EnrollmentReportActReport>(); // List<Biz.Model.EnrollmentRecordPlus> rtnValue = new List<Model.EnrollmentRecordPlus>(); List <Biz.Model.Course> Courses = new List <Model.Course>(); var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; RestClient client = new RestClient(WebcoursesUri); RestRequest request = new RestRequest(); if (enrollment_term_id == "-1") { request = new RestRequest(string.Format(cPUBLISHED_COURSES_ALL, accountID), Method.GET); } else { request = new RestRequest(string.Format(cPUBLISHED_COURSES, accountID, enrollment_term_id), Method.GET); } addAuth(ref request); var response = client.Execute(request); Courses.AddRange(JsonConvert.DeserializeObject <List <Biz.Model.Course> >(response.Content, settings)); string link = NextLink(response); while (link.Length != 0) { request = new RestRequest(link.Substring(1, link.Length - 2).Substring(WebcoursesUri.Length + 1), Method.GET); addAuth(ref request); response = client.Execute(request); Courses.AddRange(JsonConvert.DeserializeObject <List <Biz.Model.Course> >(response.Content, settings)); link = NextLink(response); } System.Diagnostics.Debug.Print("Course Pull Done!"); System.Diagnostics.Debug.Print("-Course Count = " + Courses.Count.ToString()); int i = 0; List <Model.Account> accounts = getAccounts("1"); accounts.Add(getAccount(1)); foreach (Biz.Model.Course item in Courses) { Biz.Model.Account account = getAccount(item.account_id); item.account_name = account.name; item.path = GetAccountPath(item.account_id, accounts); if (account.parent_account_id != null) { item.account_parent_id = account.parent_account_id.ToString(); item.account_parent_name = getAccount(account.parent_account_id).name; } foreach (Biz.Model.EnrollmentRecord eR in getEnrollmentsbyType(item.id.ToString(), "Teacher")) { Biz.Model.EnrollmentRecordPlus erp = new Model.EnrollmentRecordPlus(eR); erp.CourseInfo = item; erp.UserEmail = getProfile(erp.user_id.ToString()).primary_email; rtnValue.Add(new Biz.Model.EnrollmentReportActReport(erp)); } System.Diagnostics.Debug.Print(i.ToString()); i++; } return(rtnValue); }
public List <Biz.Model.Course> getPublishedCourses(string accountID, string enrollment_term_id) { List <Biz.Model.Course> rtnValue = new List <Model.Course>(); var settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; RestClient client = new RestClient(WebcoursesUri); RestRequest request = new RestRequest(string.Format(cPUBLISHED_COURSES, accountID, enrollment_term_id), Method.GET); addAuth(ref request); var response = client.Execute(request); rtnValue.AddRange(JsonConvert.DeserializeObject <List <Biz.Model.Course> >(response.Content, settings)); string link = NextLink(response); while (link.Length != 0) { request = new RestRequest(link.Substring(1, link.Length - 2).Substring(WebcoursesUri.Length + 1), Method.GET); addAuth(ref request); response = client.Execute(request); rtnValue.AddRange(JsonConvert.DeserializeObject <List <Biz.Model.Course> >(response.Content, settings)); link = NextLink(response); } foreach (Biz.Model.Course item in rtnValue) { Biz.Model.Account account = getAccount(item.account_id); item.account_name = account.name; if (account.parent_account_id != null) { item.account_parent_id = account.parent_account_id.ToString(); item.account_parent_name = getAccount(account.parent_account_id).name; } //item.cntTeachers = getEnrollmentsbyType(item.id.ToString(), "Teacher").Count; // item.cntTAs = getEnrollmentsbyType(item.id.ToString(), "TA").Count; // item.cntStudents = getEnrollmentsbyType(item.id.ToString(), "Student").Count; // item.cntObservers = getEnrollmentsbyType(item.id.ToString(), "Observers").Count; // item.cntDesigners = getEnrollmentsbyType(item.id.ToString(), "Designers").Count; item.Tabs = GetCourseTabs(item.id.ToString()).FindAll(e => e.label == "Syllabus" && e.hidden != true); if (item.Tabs.Count > 0) { item.SyllabusLink = item.Tabs.First(e => e.label == "Syllabus").full_url; } item.Tabs = null; } return(rtnValue); }