Esempio n. 1
0
        public EditEntryViewModel(string listId, string entryId, string entryImageId)
        {
            this.UseLocation = true;

            this.ListId = listId;
            this.EntryId = entryId;

            if (this.entry == null)
                this.entry = new Models.Entry();

            if (this.entryImage == null)
                this.entryImage = new Models.EntryImage();

            if (string.IsNullOrEmpty(entryId))
            {
                //Load the nearest place name, if possible
                var geo = this.GetService<Interfaces.IGeolocator>();

                if (geo.CurrentPosition != null)
                {
                    geo.LookupNearbyPlaces((nearestPlaceName) =>
                    {
                        if (!string.IsNullOrEmpty(nearestPlaceName) && string.IsNullOrEmpty(this.entry.Store))
                        {
                            this.entry.Store = nearestPlaceName;
                            RaisePropertyChanged("Entry");
                        }
                    });
                }
            }
        }
Esempio n. 2
0
        public void LoadEntry()
        {
            if (string.IsNullOrEmpty(this.EntryId))
            {
                return;
            }

            this.IsLoading = true;

            App.Azure.GetTable <Models.Entry>().LookupAsync(this.EntryId).ContinueWith((t) =>
            {
                var ex = t.Exception;

                if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                {
                    this.entry = t.Result;
                    RaisePropertyChanged("Entry");

                    App.Azure.GetTable <Models.EntryImage>().Where(ei => ei.ImageGuid == this.entry.ImageGuid).ToListAsync().ContinueWith((t2) =>
                    {
                        var ex2 = t2.Exception;

                        if (t2.Status == System.Threading.Tasks.TaskStatus.RanToCompletion && t2.Result.Count > 0)
                        {
                            this.entryImage = t2.Result[0];
                            RaisePropertyChanged("EntryImage");
                            RaisePropertyChanged("HasImage");
                        }
                    });
                }

                this.IsLoading = false;
            });

            if (this.entry == null)
            {
                this.entry = new Models.Entry();
            }

            if (this.entryImage == null)
            {
                this.entryImage = new Models.EntryImage();
            }
        }
Esempio n. 3
0
        public void LoadEntry()
        {
            this.IsLoading = true;

            App.Azure.GetTable<Models.Entry>().LookupAsync(this.EntryId).ContinueWith((t) =>
            {
                var ex = t.Exception;

                if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                {
                    this.entry = t.Result;
                    RaisePropertyChanged("Entry");

                    if (!string.IsNullOrEmpty(this.entry.ImageGuid))
                    {
                        App.Azure.GetTable<Models.EntryImage>().Where(ei => ei.ImageGuid == this.entry.ImageGuid).ToListAsync().ContinueWith((t2) =>
                        {
                            var ex2 = t2.Exception;

                            if (t2.Status == System.Threading.Tasks.TaskStatus.RanToCompletion
                                && t2.Result.Count > 0)
                            {
                                this.entryImage = t2.Result[0];
                                RaisePropertyChanged("EntryImage");
                                RaisePropertyChanged("HasImage");
                            }

                            this.IsLoading = false;
                        });
                    }
                    else
                        this.IsLoading = false;
                }
                else
                {
                    this.IsLoading = false;
                    this.ReportError("Could not load Item!");
                }
            });
        }