Beispiel #1
0
        public void UpdateRating(DynamicListData <User> users, Action onFinish)
        {
            /* TODO reativar ranking AppController */

            UserDialogs.Instance.ShowLoading(AppResources.LoadingRanking);

            var parameters = new KinveyDownloadListParameters(KinveyDownloadCountType.FirstPage,
                                                              QueryBuilder.Instance.GetRankingKinveyQuery());

            var requestTask = new DownloadUsersBackgroundTask(AppModel.Instance.Users, parameters);

            requestTask.ContinueWith((task, result) =>
            {
                UserDialogs.Instance.HideLoading();

                if (result == null)
                {
                    AppProvider.PopUpFactory.ShowMessage(AppResources.FailedServer, AppResources.Error);
                }
                else
                {
                    users.ClearData();
                    users.UpdateData(result);

                    Device.BeginInvokeOnMainThread(onFinish);
                }
            });
            _backgroundWorkers[AppBackgroundWorkerType.DownloadRanking].Add(requestTask);
        }
Beispiel #2
0
 void OnConnectionsChanged(List <ConnectRequest> connections)
 {
     AcceptedConnections.UpdateData(connections.FindAll(temp => temp.Accepted));
 }
Beispiel #3
0
        public void LoadAppData()
        {
            //			AppProvider.Log.WriteLine (Conarh_2016.Core.Services.LogChannel.All, "GetPoints " + 20.ToString() + AppResources.GetLevelImageByPoints (20));
            //			AppProvider.Log.WriteLine (Conarh_2016.Core.Services.LogChannel.All, "GetPoints " + 120.ToString() + AppResources.GetLevelImageByPoints (120));
            //			AppProvider.Log.WriteLine (Conarh_2016.Core.Services.LogChannel.All, "GetPoints " + 200.ToString() + AppResources.GetLevelImageByPoints (200));
            //
            //			AppProvider.Log.WriteLine (Conarh_2016.Core.Services.LogChannel.All, "GetPoints " + 349.ToString() + AppResources.GetLevelImageByPoints (349));
            //			AppProvider.Log.WriteLine (Conarh_2016.Core.Services.LogChannel.All, "GetPoints " + 580.ToString() + AppResources.GetLevelImageByPoints (580));
            //			AppProvider.Log.WriteLine (Conarh_2016.Core.Services.LogChannel.All, "GetPoints " + 998.ToString() + AppResources.GetLevelImageByPoints (998));
            //			AppProvider.Log.WriteLine (Conarh_2016.Core.Services.LogChannel.All, "GetPoints " + 1002.ToString() + AppResources.GetLevelImageByPoints (1002));

            AppInformation = DbClient.Instance.GetData <AppInformation>(AppInformation.AppDataId).Result ?? new AppInformation();

            Images = new DynamicListData <ImageData>();
            Images.UpdateData(DbClient.Instance.GetData <ImageData>().Result);

            Speakers = new DynamicListData <Speaker>();
            Speakers.UpdateData(DbClient.Instance.GetData <Speaker>().Result);

            BadgeTypes = new DynamicListData <BadgeType>();
            BadgeTypes.UpdateData(DbClient.Instance.GetData <BadgeType>().Result);

            SponsorTypes = new DynamicListData <SponsorType>();
            SponsorTypes.UpdateData(DbClient.Instance.GetData <SponsorType>().Result);

            /* TODO ARumar o load data */
            SponsorTypes.Items.Clear();

            Users = new DynamicListData <User>();
            Users.UpdateData(DbClient.Instance.GetData <User>().Result);

            Requests = new DynamicListData <ConnectRequest>();
            List <ConnectRequest> requestsData = DbClient.Instance.GetData <ConnectRequest>().Result;

            foreach (ConnectRequest request in requestsData)
            {
                /*
                 *
                 * request.Requester = Users.Find(request.RequesterId);
                 * request.Responder = Users.Find(request.ResponderId);
                 */

                request.RequesterId = request.RequesterId;
                request.ResponderId = request.ResponderId;
            }
            Requests.UpdateData(requestsData);


            /* TODO ARumar o load data */
            Exhibitors = new DynamicListData <Exhibitor>();
            List <Exhibitor> exhibitorData = DbClient.Instance.GetData <Exhibitor>().Result;

            /*
             * foreach (Exhibitor exhibitor in exhibitorData)
             *  exhibitor.SponsorType = SponsorTypes.Find(exhibitor.SponsorTypeId);
             */
            exhibitorData.Clear();
            Exhibitors.UpdateData(exhibitorData);

            PayedEvents = new DynamicListData <EventData>();
            FreeEvents  = new DynamicListData <EventData>();
            List <EventData> eventsData = DbClient.Instance.GetData <EventData>().Result;

            foreach (EventData evData in eventsData)
            {
                evData.Speechers = new List <Speaker>();
                List <string> speakersIds = JsonConvert.DeserializeObject <List <string> >(evData.SpeechersList);
                foreach (string speakerId in speakersIds)
                {
                    evData.Speechers.Add(Speakers.Find(speakerId));
                }
            }
            PayedEvents.UpdateData(eventsData.FindAll(temp => !temp.FreeAttending));
            FreeEvents.UpdateData(eventsData.FindAll(temp => temp.FreeAttending));

            WallPostLikes = new DynamicListData <WallPostLike>();
            List <WallPostLike> likesData = DbClient.Instance.GetData <WallPostLike>().Result;

            foreach (WallPostLike like in likesData)
            {
                like.User = Users.Find(like.UserId);
            }
            WallPostLikes.UpdateData(likesData);

            WallPosts = new DynamicListData <WallPost>();
            List <WallPost> wallPostData = DbClient.Instance.GetData <WallPost>().Result;

            foreach (WallPost wallPost in wallPostData)
            {
                wallPost.CreatedUser = Users.Find(wallPost.CreatedUserId);

                List <WallPostLike> likes = WallPostLikes.Items.FindAll(temp => temp.Post.Equals(wallPost.Id));
                foreach (WallPostLike likeData in likes)
                {
                    wallPost.LikeList.Add(likeData.User);
                }
            }
            WallPosts.UpdateData(wallPostData);

            ExhibitorsWrapper  = new ExhibitorsDataWrapper(SponsorTypes, Exhibitors, false);
            FreeEventsWrapper  = new EventsDataWrapper(FreeEvents);
            PayedEventsWrapper = new EventsDataWrapper(PayedEvents);
            WallPostsWrapper   = new WallPostsDataWrapper(WallPosts);
            UsersModelsWrapper = new UserModelsWrapper(Users);

            FreeEventsGridWrapper  = new EventsGridWrapper(FreeEvents);
            PayedEventsGridWrapper = new EventsGridWrapper(PayedEvents);
        }