Exemplo n.º 1
0
        public async Task FilterLearningResources(string type, string technology, string role)
        {
            this.SelectedType       = type ?? "";
            this.SelectedRole       = role ?? "";
            this.SelectedTechnology = technology ?? "";

            ObservableCollection <LearningResource> model;

            model = await LearningResourceService.GetLearningResourcesFromLocal();

            if (model == null)
            {
                await MessageHelper.ShowMessage("Please connect to internet to download learning resources");

                return;
            }

            var list = (from c in model
                        where
                        (this.SelectedTechnology == "" || SelectedTechnology == "All" ||
                         c.PrimaryTechnologyName == this.SelectedTechnology) &&
                        (SelectedRole == "" || SelectedRole == "All" || c.AudienceTypes.FirstOrDefault(x => x.AudienceTypeName == SelectedRole) != null) &&
                        (SelectedType == "" || SelectedType == "All" ||
                         c.LearningResourceType == SelectedType)
                        select c).ToList();

            this.AllLearningResources = new ObservableCollection <LearningResource>(list);
            this.ShowAll = true;
        }
Exemplo n.º 2
0
        public async Task GetLearningResources()
        {
            this.AllResources = await LearningResourceService.GetLearningResourcesFromLocal();

            OnPropertyChanged("Technologies");
            OnPropertyChanged("Types");
            OnPropertyChanged("Roles");
        }
Exemplo n.º 3
0
        public async Task GetLearningContent()
        {
            this.OperationInProgress = true;
            try
            {
                LearningResourcesRequest request = new LearningResourcesRequest()
                {
                    RequestedPageNo = 1,
                    SourceType      = "All",
                    Technologies    = new List <string>(),
                    UserRole        = "All"
                };


                ObservableCollection <LearningResource> model =
                    await LearningResourceService.GetLearningResourcesFromLocal();

                await SetLearningContent(model);

                if (NetworkHelper.IsNetworkAvailable() == false)
                {
                    if (model == null)
                    {
                        await MessageHelper.ShowMessage("Please connect to internet to download learning resources");

                        return;
                    }
                }
                else
                {
                    var result = await LearningResourceService.GetLearningResourcesFromServer(request);

                    if (result != null)
                    {
                        model = result;
                        await LearningResourceService.SaveLearningResources(model);
                    }
                    else
                    {
                        //await MessageHelper.ShowMessage(result.Error.Message);
                    }
                }

                var favVideos =
                    await LocalStorage.ReadJsonFromFile <ObservableCollection <LearningResource> >("watchedVideos");

                foreach (var flr in favVideos)
                {
                    var lr = model.Where(x => x.LearningResourceID == flr.LearningResourceID).FirstOrDefault();
                    if (lr != null)
                    {
                        lr.Favourited = true;
                    }
                }
                await SetLearningContent(model);
            }
            catch (Exception)
            {
            }
            finally
            {
                this.OperationInProgress = false;
            }
        }