예제 #1
0
 public SchoolUsersViewModel(School School, ArrayResult <SectionUser> users, ArrayResult <SectionUser> students, ArrayResult <SectionUser> teachers)
 {
     this.School   = School;
     this.Users    = users;
     this.Students = students;
     this.Teachers = teachers;
 }
예제 #2
0
        public async Task <SearchResult> GetResultAsync(string AppName)
        {
            string changedName = AppName.Replace(" ", "+");

            var currentUrl = settings.BaseUrl.Replace("*Name*", changedName);


            var client = new RestClient(currentUrl);

            client.UserAgent = "User";
            var request = new RestRequest(Method.GET);

            request.AddHeader("x-rapidapi-host", settings.Rapidapi_host);
            request.AddHeader("x-rapidapi-key", settings.Rapidapi_key);
            IRestResponse response = await client.ExecuteAsync(request);

            JObject     search  = JObject.Parse(response.Content);
            ArrayResult results = JsonConvert.DeserializeObject <ArrayResult>(search.ToString());

            if (results.Results is null)
            {
                return(null);
            }
            return(results.Results.FirstOrDefault());
        }
예제 #3
0
 public SectionsViewModel(string userEmail, EducationSchool school, ArrayResult <EducationClass> classes, IEnumerable <EducationClass> myClasses)
 {
     this.UserEmail = userEmail;
     this.School    = school;
     this.Classes   = classes;
     this.MyClasses = myClasses.ToList();
 }
예제 #4
0
 public SectionsViewModel(string userEmail, School School, ArrayResult <Section> sections, IEnumerable <Section> mySections)
 {
     this.UserEmail  = userEmail;
     this.School     = School;
     this.Sections   = sections;
     this.MySections = mySections.ToList();
 }
예제 #5
0
 public SectionsViewModel(UserContext userContext, EducationSchool school, ArrayResult <EducationClass> classes, IEnumerable <EducationClass> myClasses)
 {
     this.UserEmail   = userContext.UserO365Email;
     this.School      = school;
     this.Classes     = classes;
     this.MyClasses   = myClasses.ToList();
     this.UserContext = userContext;
 }
예제 #6
0
 public SectionsViewModel(UserContext userContext, School School, ArrayResult <Section> sections, IEnumerable <Section> mySections)
 {
     this.UserEmail   = userContext.UserO365Email;
     this.School      = School;
     this.Sections    = sections;
     this.MySections  = mySections.ToList();
     this.UserContext = userContext;
 }
예제 #7
0
 public SchoolUsersViewModel(UserContext userContext, EducationSchool School, ArrayResult <EducationUser> users, ArrayResult <EducationUser> students, ArrayResult <EducationUser> teachers, ArrayResult <EducationUser> studentsInMyClasses)
 {
     this.School              = School;
     this.Users               = users;
     this.Students            = students;
     this.Teachers            = teachers;
     this.StudentsInMyClasses = studentsInMyClasses;
     this.UserContext         = userContext;
 }
예제 #8
0
        public void TestExecute2()
        {
            ActionDescriptor actionDescriptor = new ActionDescriptor()
            {
                ActionName = "yari_test_2",
                ResultType = ResultType.Array,
            };

            ArrayResult <Model1> result = actionManager.Execute <ArrayResult <Model1> >(actionDescriptor);

            Assert.IsNotNull(result);
        }
        /// <summary>
        /// Get users, teachers and students of the specified school
        /// </summary>
        public async Task <SchoolUsersViewModel> GetSchoolUsersAsync(UserContext userContext, string objectId, int top)
        {
            var school = await educationServiceClient.GetSchoolAsync(objectId);

            var users = await educationServiceClient.GetMembersAsync(objectId, top, null);

            var students = await educationServiceClient.GetStudentsAsync(school.SchoolNumber, top, null);

            var teachers = await educationServiceClient.GetTeachersAsync(school.SchoolNumber, top, null);

            ArrayResult <SectionUser> studentsInMyClasses = null;

            if (userContext.IsFaculty)
            {
                var mySections = await educationServiceClient.GetMySectionsAsync(true);

                studentsInMyClasses = new ArrayResult <SectionUser>();
                List <SectionUser> studentsList = new List <SectionUser>();
                foreach (var item in mySections)
                {
                    if (item.SchoolId == school.SchoolId)
                    {
                        foreach (var user in item.Members)
                        {
                            if (user.ObjectType == "Student" && studentsList.Where(c => c.O365UserId == user.O365UserId).Count() == 0)
                            {
                                studentsList.Add(user);
                            }
                        }
                    }
                }

                studentsInMyClasses.Value = studentsList.ToArray();
            }
            return(new SchoolUsersViewModel(userContext, school, users, students, teachers, studentsInMyClasses));
        }