Example #1
0
        public void TestServerServiceUpdateAccount()
        {
            var userService            = new UserService();
            var userConferenceService  = new UserConferenceService();
            var adminConferenceService = new AdminConferenceService();
            var proposalService        = new ProposalService();
            var reviewService          = new ReviewService();
            var ticketService          = new TicketService();
            var enumService            = new EnumGetDataService();
            var emailService           = new EmailService();
            var sectionService         = new SectionService();
            var serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);

            PrepareData();


            Assert.AreEqual(4, serverService.findAll().ToList().Count);
            var userForUpdate = serverService.findUser(1);

            userForUpdate.FirstName = "Pop";
            userForUpdate.LastName  = "Mihai";
            userForUpdate.Username  = "******";

            var updatedUser      = serverService.updateAccount(userForUpdate);
            var userFromDataBase = serverService.findUser(updatedUser.Id);

            Assert.AreEqual(4, serverService.findAll().ToList().Count);
            Assert.AreEqual("Pop", updatedUser.FirstName);
            Assert.AreEqual("Mihai", updatedUser.LastName);
            Assert.AreEqual("Updated", updatedUser.Username);
            Assert.AreEqual("Pop", userFromDataBase.FirstName);
            Assert.AreEqual("Mihai", userFromDataBase.LastName);
            Assert.AreEqual("Updated", userForUpdate.Username);
        }
Example #2
0
        public void TestServerServiceFindUser()
        {
            PrepareData();
            var userService            = new UserService();
            var userConferenceService  = new UserConferenceService();
            var adminConferenceService = new AdminConferenceService();
            var proposalService        = new ProposalService();
            var reviewService          = new ReviewService();
            var ticketService          = new TicketService();
            var enumService            = new EnumGetDataService();
            var emailService           = new EmailService();
            var sectionService         = new SectionService();
            var serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);

            var user1 = serverService.findUser(1);
            var user3 = serverService.findUser(3);

            Assert.AreEqual("User1", user1.Username);
            Assert.AreEqual("User3", user3.Username);
            Assert.AreEqual("Last1", user1.LastName);
            Assert.AreEqual("Last3", user3.LastName);
            Assert.AreEqual("First1", user1.FirstName);
            Assert.AreEqual("First3", user3.FirstName);
            Assert.AreEqual(true, user1.Admin);
            Assert.AreEqual(false, user3.Admin);
        }
Example #3
0
        public void AddControlRecruiter2011(SimplePageVM model)
        {
            var sections = SectionService.GetAll(x => new[] { 370, 371 }.Contains(x.Section_ID)).ToList();

            model.Controls.Add(
                new SimplePageVM.Control(Views.Page.Recruiter2011, sections));
        }
        //Helper methods
        private SectionService CreateSectionService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SectionService(userId);

            return(service);
        }
Example #5
0
        public void Create_A_Section_With_Unique_Code()
        {
            // Arrange
            SectionService _sectionService = new SectionService();
            List <Section> sections        = new List <Section>();
            Guid           childrens_guid  = Guid.NewGuid();
            Guid           teens_guid      = Guid.NewGuid();
            Guid           adults_guid     = Guid.NewGuid();

            Section childrens_section = new Section {
                Id = childrens_guid, Code = "CHLD", Name = "Children", Description = "Children Aged 0-12"
            };
            Section teens_section = new Section {
                Id = teens_guid, Code = "CHLD", Name = "Teenage", Description = "Children Aged 13-15"
            };
            Section adults_section = new Section {
                Id = adults_guid, Code = "ADLT", Name = "Adult", Description = "Adults Aged 16+"
            };

            // Act
            bool childrens_result = _sectionService.Add(childrens_section, sections);
            bool teens_result     = _sectionService.Add(teens_section, sections);
            bool adults_result    = _sectionService.Add(adults_section, sections);

            // Assert
            Assert.AreEqual(true, childrens_result);
            Assert.AreEqual(false, teens_result);
            Assert.AreEqual(true, adults_result);
            Assert.AreEqual(2, sections.Count);
        }
Example #6
0
        public void Delete_A_Section()
        {
            // Arrange
            SectionService _sectionService = new SectionService();
            List <Section> sections        = new List <Section>();
            Guid           childrens_guid  = Guid.NewGuid();
            Guid           teens_guid      = Guid.NewGuid();
            Guid           adults_guid     = Guid.NewGuid();

            Section childrens_section = new Section {
                Id = childrens_guid, Code = "CHLD", Name = "Children", Description = "Children Aged 0-12"
            };
            Section teens_section = new Section {
                Id = teens_guid, Code = "TEEN", Name = "Teenage", Description = "Children Aged 13-15"
            };
            Section adults_section = new Section {
                Id = adults_guid, Code = "ADLT", Name = "Adult", Description = "Adults Aged 16+"
            };

            _sectionService.Add(childrens_section, sections);
            _sectionService.Add(teens_section, sections);
            _sectionService.Add(adults_section, sections);

            // Act
            bool result = _sectionService.Delete(adults_guid, sections);

            // Assert
            Assert.AreEqual(2, sections.Count);
            CollectionAssert.DoesNotContain(sections, adults_section);
        }
Example #7
0
        public async Task UpdateSection_UpdatesExistingSection()
        {
            var section = new Section
            {
                SectionString = "Section 1",
                InstructorId  = 1
            };

            using (var context = new ApplicationDbContext(Options))
            {
                context.Sections.Add(section);
                context.SaveChanges();
            }

            section.SectionString = "Updated section";
            using (var context = new ApplicationDbContext(Options))
            {
                var     service        = new SectionService(context);
                Section updatedSection = await service.UpdateSection(section);

                Assert.AreEqual(section, updatedSection);
            }

            using (var context = new ApplicationDbContext(Options))
            {
                Section retrievedSection = context.Sections.Single();
                Assert.AreEqual(section.Id, retrievedSection.Id);
                Assert.AreEqual(section.SectionString, retrievedSection.SectionString);
                Assert.AreEqual(section.InstructorId, retrievedSection.InstructorId);
            }
        }
Example #8
0
        public void TestServerServiceCreateAccount()
        {
            var     userService            = new UserService();
            var     userConferenceService  = new UserConferenceService();
            var     adminConferenceService = new AdminConferenceService();
            var     proposalService        = new ProposalService();
            var     reviewService          = new ReviewService();
            var     ticketService          = new TicketService();
            var     enumService            = new EnumGetDataService();
            var     emailService           = new EmailService();
            var     sectionService         = new SectionService();
            var     serverService          = new ServerService(userService, userConferenceService, adminConferenceService, ticketService, emailService, proposalService, enumService, reviewService, sectionService);
            UserDTO userToAdd = new UserDTO()
            {
                Username   = "******",
                Password   = "******",
                FirstName  = "User",
                LastName   = "ForTest",
                Email      = "*****@*****.**",
                WebPage    = "test.ro",
                Admin      = true,
                Validation = "Waiting"
            };

            Assert.AreEqual(0, serverService.findAll().ToList().Count);
            var userSaved = serverService.createAccount(userToAdd);

            Assert.AreEqual(1, serverService.findAll().ToList().Count);
            Assert.AreEqual("UserForTest", serverService.findUser(userSaved.Id).Username);
            Assert.AreEqual("test.ro", userSaved.WebPage);
        }
Example #9
0
        public ActionResult SectionTrainers(string urlName)
        {
            var section = SectionService.GetAll().ByUrlName(urlName);

            if (section == null)
            {
                return(null);
            }
            var courseTCs = CourseVMService
                            .GetCourseTCListForTotalSection(section.Section_ID);

            var groups = GroupService.GetGroupsForCourses(courseTCs)
                         .Where(g => g.Teacher_TC != null).ToList();
            var groupCountByTrainers = groups.GroupBy(x => x.Teacher_TC)
                                       .ToDictionary(x => x.Key, x => x.Count());
            var trainers = groups
                           .Select(x => x.Teacher)
                           .Distinct(x => x.Employee_TC)
                           .Select(x => new { Teacher = x,
                                              Count   = groupCountByTrainers.GetValueOrDefault(x.Employee_TC) })
                           .Where(x => x.Teacher.FinalSiteVisible && x.Count > 0)
                           .OrderByDescending(x => x.Count).Select(x => x.Teacher)
                           .ToList();

            return(View(ViewNames.Trainers, CommonVM.New(trainers, "Преподаватели направления: " + section.Name)));
        }
Example #10
0
        public virtual void Index()
        {
            ContentApp     app     = ctx.app.obj as ContentApp;
            ContentSetting setting = app.GetSettingsObj();

            ctx.Page.Title       = ctx.app.Name;
            ctx.Page.Description = setting.MetaDescription;

            if (strUtil.HasText(setting.MetaKeywords))
            {
                this.Page.Keywords = setting.MetaKeywords;
            }
            else
            {
                this.Page.Keywords = ctx.app.Name;
            }

            set("app.Style", app.Style);
            set("app.SkinStyle", app.SkinStyle);
            set("lnkSendPost", to(new Submit.PostController().Index));

            List <ContentSection> sections = SectionService.GetByApp(ctx.app.Id);

            bindRows(app, sections);
        }
Example #11
0
        /// <summary>
        /// 得到职员的详细信息
        /// </summary>
        /// <returns></returns>
        public async Task <List <StaffSimpleInfoDto> > GetAllStaffDetial()
        {
            var staffDetailList = new List <StaffSimpleInfoDto>();

            using (StaffInfoService staffInfoService = new StaffInfoService())
            {
                var staffList = await staffInfoService.GetAll().ToListAsync();

                using (SectionService sectionService = new SectionService())
                {
                    foreach (var item in staffList)
                    {
                        var sn = (await sectionService.GetOneById(item.SectionId)).Name;
                        staffDetailList.Add(new StaffSimpleInfoDto()
                        {
                            Id          = item.Id,
                            Name        = item.Name,
                            Tel         = item.Tel,
                            Email       = item.Email,
                            SectionName = sn,
                            Position    = item.Position,
                            Status      = item.Status,
                            CreateTime  = item.CreatTime,
                            Address     = item.Address,
                            Photo       = item.ImagePath,
                            IdCard      = item.IdCard
                        });
                    }
                }
            }
            return(staffDetailList);
        }
        public static async Task<SectionDisplayObject> GetSectionDisplayObject(SectionService ss, Section section)
        {
            //check to see if the item is already in cache. if so, return the cache item
            var cache = (SectionDisplayObject)HttpContext.Current.Cache[section.id];
            if (cache != null)
                return cache;

            var courseOfferingCache = (CourseOffering)HttpContext.Current.Cache[section.courseOfferingId];
            if (courseOfferingCache == null){
                var courseOfferings = await GetAllCourseOfferings(ss);
                courseOfferingCache = courseOfferings.FirstOrDefault(co => co.id == section.courseOfferingId);
            }

            var courseCache = new Course();
            if (courseOfferingCache != null)
            {
                courseCache = (Course)HttpContext.Current.Cache[courseOfferingCache.courseId];
                if (courseCache == null)
                {
                    var courses = await GetAllCourses(ss);
                    courseCache = courses.FirstOrDefault(c => c.id == courseOfferingCache.courseId);
                }
            }
                                      
            var sdo = MapSectionToSectionDisplayObject(courseCache, section.id);

            HttpContext.Current.Cache.Insert(section.id, sdo);
            return sdo;
        }
Example #13
0
        public BorrowBookTransaction(LibraryUser libUser, BookCopy bookCopy)
            : base(bookCopy)
        {
            _BookCopyService = new BookCopyService();
            _HolidayService  = new HolidayService();
            _BookInfoService = new BookService();
            _SectionService  = new SectionService();

            var bookInfo = _BookInfoService.BookInfoOf(BookCopy);
            var section  = _SectionService.GetBookSection(bookInfo);

            if (section == null)
            {
                throw new InvalidOperationException("The book does not belong to a section.");
            }

            if (section.MaxDaysAllowedForBorrowing == 0)
            {
                TransactionType = "Not Allowed For Borrowing.";
            }

            bookTransInfo = new TransactionInfo
            {
                BookCopyId         = BookCopy.Id,
                LibraryUserId      = libUser.Id,
                BorrowDate         = TransactionDate,
                ExpectedReturnDate = _HolidayService.GetNonHolidayDateFrom(TransactionDate.AddDays(section.MaxDaysAllowedForBorrowing))
            };
        }
Example #14
0
 /// <summary>
 /// 根据ID得到部门名称
 /// </summary>
 /// <param name="id">部门ID</param>
 /// <returns>部门名称</returns>
 public string GetSectionNameById(Guid id)
 {
     using (ISectionService sectionService = new SectionService())
     {
         return(sectionService.GetAll().Where(p => p.Id == id).FirstOrDefault().Name);
     }
 }
Example #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TodoistClient" /> class.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="restClient">The rest client.</param>
        /// <exception cref="System.ArgumentException">Value cannot be null or empty - token</exception>
        public TodoistClient(string token, ITodoistRestClient restClient)
        {
            if (string.IsNullOrEmpty(token))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(token));
            }

            _token      = token;
            _restClient = restClient;

            Projects      = new ProjectsService(this);
            Templates     = new TemplateService(this);
            Items         = new ItemsService(this);
            Labels        = new LabelsService(this);
            Notes         = new NotesService(this);
            Uploads       = new UploadService(this);
            Filters       = new FiltersService(this);
            Activity      = new ActivityService(this);
            Notifications = new NotificationsService(this);
            Backups       = new BackupService(this);
            Reminders     = new RemindersService(this);
            Users         = new UsersService(this);
            Sharing       = new SharingService(this);
            Emails        = new EmailService(this);
            Sections      = new SectionService(this);
        }
 public void SyncToCanvas()
 {
     CourseService.SyncToCanvas();
     SectionService.SyncToCanvas();
     UserService.SyncToCanvas();
     InscriptionService.SyncToCanvas();
 }
Example #17
0
        public SectionPageViewModel(SectionService sectionService)
        {
            _SectionService = sectionService;

            items = new ObservableCollection <Section>(_SectionService.GetAllSections());
            ItemsCollectionView = (CollectionView)CollectionViewSource.GetDefaultView(items);
        }
Example #18
0
        public ActionResult ChooseSectionResponses()
        {
            var controlModel =
                SectionService.GetTreeWithSubsections();

            return(View(CommonVM.New(controlModel, "Отзывы по направлениям")));
        }
Example #19
0
 /// <summary>
 /// 得到所有的部门
 /// </summary>
 /// <returns></returns>
 public async Task <string[]> GetAllSections()
 {
     using (ISectionService sectionService = new SectionService())
     {
         return(await sectionService.GetAllOrder().Select(p => p.Name).ToArrayAsync());
     }
 }
Example #20
0
        public async Task AddSection_PersistsSection()
        {
            var section = new Section
            {
                SectionString = "Section 1",
                InstructorId  = 1
            };

            using (var context = new ApplicationDbContext(Options))
            {
                var service = new SectionService(context);

                Section addedSection = await service.AddSection(section);

                Assert.AreEqual(addedSection, section);
                Assert.AreNotEqual(0, addedSection.Id);
            }

            using (var context = new ApplicationDbContext(Options))
            {
                Section retrievedSection = context.Sections.Single();
                Assert.AreEqual(section.SectionString, retrievedSection.SectionString);
                Assert.AreEqual(section.InstructorId, retrievedSection.InstructorId);
            }
        }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SectionService   sectionService = new SectionService();
            HousetypeService hyService      = new HousetypeService();
            AreaService      areaSevice     = new AreaService();

            sectionList = sectionService.GetModelList("");
            hyList      = hyService.GetModelList("");
            areaList    = areaSevice.GetModelList("");

            hid = Int32.Parse(Request["hid"]);

            house = houseService.GetModel(hid);

            hmode = (int)house.hmode;

            sid = house.sid;

            htype = (int)house.htype;

            areaid = (int)house.harea;

            if (IsPostBack)
            {
                this.update();
            }
        }
Example #22
0
        public SectionViewViewModel(SectionService sectionService)
        {
            sectionService.SectionsChanged += this.OnSectionsChanged;

            this.selectWorldEvent.Subscribe(
                i =>
            {
                this.worlds.OnNext(this.worlds.Value.Select(i));

                this.UpdateCategories();
                this.UpdateSections();
            });

            this.selectCategoryEvent.Subscribe(
                i =>
            {
                this.categories.OnNext(this.categories.Value.Select(i));

                this.UpdateSections();
            });

            this.sectionService = sectionService;

            this.SectionType = SectionType.Section;
        }
        public void TestGetCommunityById()
        {
            var            context        = TestUtils.GetDbContext();
            SectionService sectionService = TestUtils.CreateService <SectionService>(context);

            sectionService.GetByComunityId(new Guid("f42c48cf-c90f-4d71-a501-b88c4165efee"));
        }
Example #24
0
        /// <summary>
        /// 查询所有的职员
        /// </summary>
        /// <returns></returns>
        public async Task <List <StaffSimpleInfoDto> > QueryAllStaff()
        {
            using (var staffInfoService = new StaffInfoService())
            {
                List <StaffSimpleInfoDto> staffDtoList = new List <StaffSimpleInfoDto>();
                var staffList = await staffInfoService.GetAllOrder().ToListAsync();

                using (var sectionService = new SectionService())
                {
                    foreach (var staff in staffList)
                    {
                        string sectionName = sectionService.GetAll().Where(p => p.Id == staff.SectionId).FirstOrDefault().Name;
                        staffDtoList.Add(new StaffSimpleInfoDto()
                        {
                            Id          = staff.Id,
                            Name        = staff.Name,
                            Tel         = staff.Tel,
                            Position    = staff.Position,
                            Status      = staff.Status,
                            Email       = staff.Email,
                            SectionName = sectionName
                        });
                    }
                }
                return(staffDtoList);
            }
        }
Example #25
0
        public ActionResult PrivatePerson(string urlName, int?pageIndex)
        {
            if (!pageIndex.HasValue && urlName != SimplePages.Urls.Works)
            {
                return(RedirectToAction(() => PrivatePerson(urlName, 1)));
            }
            var index = pageIndex.GetValueOrDefault() - 1;

            var model = new PrivatePersonVM();

            model.UrlName = urlName;
            if (model.IsSuccessStories)
            {
                model.SuccessStories = SuccesStoryService.GetAll()
                                       .IsActive().OrderByDescending(s => s.SuccessStoryID).ToPagedList(index, 10);
            }

            else if (model.IsResponses)
            {
                model.Responses = ResponseService.GetAll().IsActive()
                                  .OrderByDescending(x => x.Rating)
                                  .ThenByDescending(r => r.ResponseID).ToPagedList(index, 10);
            }

            else if (model.IsUserWorks)
            {
                var temp =
                    (from x in UserWorkService.GetAll().IsActive()
                     where !x.Section.IsMain
                     group x by x.Section_ID
                     into gr
                     select
                     new {
                    Section = gr.Key,
                    WorkSections = gr.Select(x => x.UserWorkSection).Distinct()
                }).ToDictionary(x => x.Section, x => x.WorkSections.ToList());
                var tree         = SectionService.GetSectionsTree();
                var allSections  = temp.Select(x => x.Key).ToList();
                var rootSections =
                    tree.Select(x =>
                                new {
                    Root     = x,
                    Sections = x.SubSections.Where(ss =>
                                                   allSections.Contains(ss.Section_ID)).ToList()
                })
                    .Where(x => x.Sections.Any()).ToList();

                model.UserWorks = rootSections.Select(x => EntityWithList.New(x.Root,
                                                                              x.Sections.Select(y => EntityWithList.New(y,
                                                                                                                        temp.GetValueOrDefault(y.Section_ID)))))
                                  .ToList();
            }
            else
            {
                return(RedirectToAction(() => PrivatePerson(SimplePages.Urls.SuccessStories, 1)));
            }

            return(View(model));
        }
Example #26
0
        public ActionResult MainPageSections()
        {
            var sections = SectionService.AllActiveSections().Where(x => x.ForMainPage)
                           .OrderBy(x => x.WebSortOrder).ToList();

            return(Content(Htmls2.MarkArrow(sections.Select(x =>
                                                            Html.SectionLink(x))).ToString()));
        }
Example #27
0
        private async Task InitSections()
        {
            var _sectionService = new SectionService();

            _sections = await _sectionService.GetSections();

            await Task.CompletedTask;
        }
Example #28
0
 public PaymentService()
 {
     _SectionService                = new SectionService();
     _BookInfoService               = new BookService();
     _BookCopyService               = new BookCopyService();
     _LibraryUserService            = new LibraryUserService();
     _BookTransactionInfoRepository = new BookTransactionInfoRepository();
 }
Example #29
0
        public void SyncToCanvas()
        {
            logger.Info("SectionController/SyncToCanvas - Task 'Sync section' STARTED");

            SectionService.SyncToCanvas();

            logger.Info("SectionController/SyncToCanvas - Task 'Sync section' FINISHED");
        }
Example #30
0
        public static void Main()
        {
            bugsnagClient = new Bugsnag.Client(new Bugsnag.Configuration
            {
                ApiKey     = "fa43381b116de659fcf1cfda14884d98",
                AppVersion = Application.ProductVersion,
                AutoNotify = false
            });

            // install custom handler for fatal exceptions
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            // route UI thread exceptions to the fatal exception handler
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);

            RemoveOldVersionSettings();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var mainForm              = new MainForm();
            var tileCache             = new BitmapCache();
            var dialogService         = new DialogService(mainForm);
            var featureService        = new FeatureService();
            var sectionsService       = new SectionService();
            var sectionFactory        = new SectionFactory(tileCache);
            var sectionBitmapService  = new SectionBitmapService(sectionFactory);
            var mapModelFactory       = new MapModelFactory(tileCache);
            var mapLoadingService     = new MapLoadingService(sectionFactory, mapModelFactory);
            var imageImportingService = new ImageImportService(tileCache);
            var model = new CoreModel();

            // Unsure if I should get the SectionViews to register themselves, or pass the dispatcher the SectionViews as params
            mainForm.SectionView.SetModel(new SectionViewViewModel(sectionsService));
            mainForm.FeatureView.SetModel(new FeatureViewViewModel(featureService));

            var dispatcher = new Dispatcher(
                model,
                dialogService,
                sectionsService,
                sectionBitmapService,
                featureService,
                mapLoadingService,
                imageImportingService,
                tileCache,
                mainForm);

            mainForm.SetModel(new MainFormViewModel(model, dispatcher));

            mainForm.MapViewPanel.SetModel(new MapViewViewModel(model, dispatcher, featureService));

            var minimapForm = new MinimapForm();

            minimapForm.Owner = mainForm;
            minimapForm.SetModel(new MinimapFormViewModel(model, dispatcher));

            Application.Run(mainForm);
        }
Example #31
0
        public async Task <IActionResult> Students(string sectionName)
        {
            var section = Classroom.Sections
                          .SingleOrDefault(s => s.Name == sectionName);

            if (section == null)
            {
                return(NotFound());
            }

            var students = await SectionService.GetSectionStudentsAsync
                           (
                ClassroomName,
                sectionName
                           );

            var studentsViewModel = new UserListViewModel
                                    (
                students
                .Select(m => m.ClassroomMembership.User)
                .OrderBy(u => u.LastName)
                .ThenBy(u => u.FirstName)
                .ToList(),

                new List <UserAction>()
            {
                new UserAction
                (
                    "Assignments",
                    user => Url.Action("Index", "Assignment", new { userId = user.Id })
                ),
                new UserAction
                (
                    "Projects",
                    user => Url.Action("Index", "Project", new { userId = user.Id })
                ),
                new UserAction
                (
                    "View",
                    user => Url.Action("View", "User", new { userId = user.Id })
                ),
                new UserAction
                (
                    "Edit",
                    user => Url.Action("Edit", "User", new { userId = user.Id })
                ),
                new UserAction
                (
                    "Remove",
                    user => Url.Action("RemoveStudent", new { userId = user.Id })
                )
            }
                                    );

            ViewBag.Section = section;

            return(View(studentsViewModel));
        }
        public static async Task<IEnumerable<Course>> GetAllCourses(SectionService ss)
        {
            try
            {
                //Get all courses
                var result = await ss.GetAllCourses();

                //cache each course by id
                foreach (var c in result)
                {
                    HttpContext.Current.Cache.Insert(c.id, c);
                }

                return result;
            }
            catch (Exception e)
            {
                ExceptionHelper.LogCaughtException(e);
                return new List<Course>();
            }           
        }
        /// <summary>
        /// Get all sections from SLI for the current user session
        /// </summary>
        /// <returns>List of all sections the current user has access to</returns>
        public async Task<IEnumerable<Section>> GetSections()
        {
            var c = new SectionService(Session["access_token"].ToString());
            var list = await c.GetAll();

            return list;
        }
        public async Task<ActionResult> Group()
        {
            var accessToken = Session["access_token"];
            if (accessToken != null)
            {
                var cs = new CohortService(accessToken.ToString());
                var ss = new StudentService(accessToken.ToString());
                var ses = new SectionService(accessToken.ToString());

                var co = GetCohorts();
                var st = GetStudents();
                var se = GetSections();

                //Get the available data elements and colors
                var dataElements = GlobalHelper.InitializeDataElements();
                var colors = GlobalHelper.InitializeColors();

                await Task.WhenAll(co, st, se);

                var cohorts = Task.WhenAll(from c in co.Result select CohortHelper.GetCohortDisplayObject(cs, c));
                var students = Task.WhenAll(from s in st.Result select StudentHelper.GetStudentDisplayObject(ss, s));
                var sections = Task.WhenAll(from s in se.Result select SectionHelper.GetSectionDisplayObject(ses, s));

                await Task.WhenAll(cohorts, students, se);

                var filters = FilterHelper.InitializeFilters(sections.Result); //contruct filter values to filter students in the app
                await Task.WhenAll(dataElements, colors);

                var data = GetGroupingDisplayObject(dataElements, colors, filters, cohorts, students, sections);

                return Json(data, JsonRequestBehavior.AllowGet);
            }

            //session has expired, refresh page
            return View("Index");
        }