Ejemplo n.º 1
0
        private void GetItemSource()
        {
            UserDialogs.Instance.ShowLoading();
            AppModel.Instance.CurrentUser.FavoriteEvents.ClearData();
            DynamicListData <EventData> allEvents = new DynamicListData <EventData>();

            if (!(AppModel.Instance.PayedEvents.Items.Count > 0) || !(AppModel.Instance.FreeEvents.Items.Count > 0))
            {
                var task1 = new DownloadEventsDataBackgroundTask(true, AppModel.Instance.FreeEvents);
                var task2 = new DownloadEventsDataBackgroundTask(false, AppModel.Instance.PayedEvents);
                task1.Execute();
                task2.Execute();
            }


            allEvents.UpdateData(AppModel.Instance.PayedEvents.Items);
            allEvents.UpdateData(AppModel.Instance.FreeEvents.Items);

            foreach (FavouriteEventData fed in AppModel.Instance.CurrentUser.FavouriteActions.Items)
            {
                EventData ed = null;

                ed = allEvents.Find(fed.EventId);
                if (ed != null)
                {
                }
                AppModel.Instance.CurrentUser.FavoriteEvents.AddOne(ed);
            }
            UserDialogs.Instance.HideLoading();
            FavEventListWrapper = new EventsDataWrapper(AppModel.Instance.CurrentUser.FavoriteEvents);
        }
Ejemplo n.º 2
0
        private void OnExhibitorsChanged(List <Exhibitor> exhibitors)
        {
            if (exhibitors == null)
            {
                return;
            }


            if (DontShowCategoryIfEmpty)
            {
                var items = new Dictionary <SponsorType, List <Exhibitor> >();
                foreach (Exhibitor exhibitor in exhibitors)
                {
                    SponsorType sponsor = Sponsors.Find(exhibitor.SponsorType.Id);
                    if (!items.ContainsKey(sponsor))
                    {
                        items.Add(sponsor, new List <Exhibitor> ());
                    }

                    items [sponsor].Add(exhibitor);
                }

                Device.BeginInvokeOnMainThread(() => {
                    foreach (SponsorType sponsorType in items.Keys)
                    {
                        if (!Data.ContainsKey(sponsorType))
                        {
                            var collection = new ExhibitorsDynamicObservableData(sponsorType);
                            Data.Add(sponsorType, collection);

                            Items.Add(collection);
                            OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, collection));
                        }
                        Data[sponsorType].UpdateData(items[sponsorType]);
                    }
                });
            }
            else
            {
                foreach (ExhibitorsDynamicObservableData data in Items)
                {
                    List <Exhibitor> lexh = new List <Exhibitor>();

                    foreach (Exhibitor exh in exhibitors)
                    {
                        if (exh.SponsorType.Type == data.Sponsor.Type)
                        {
                            lexh.Add(exh);
                        }
                    }
                    data.UpdateData(lexh);
                    //data.UpdateData(exhibitors.FindAll(temp => temp.SponsorTypeId.Equals(data.Sponsor.Type)));
                    //data.UpdateData (exhibitors.FindAll (temp => temp.SponsorType.Id.Equals (data.Sponsor.Id)));
                }
            }
        }
Ejemplo n.º 3
0
        public UserModel AddModel(User user, out bool isNew)
        {
            isNew = false;

            UserModel model = UsersModels.Find(user.Id);

            if (model == null)
            {
                model = new UserModel(user);
                isNew = true;
                UsersModels.Items.Add(model);
            }
            else
            {
                if (model.User.UpdatedAtTime < user.UpdatedAtTime)
                {
                    model.UpdateUser(user);
                }
            }

            return(model);
        }