コード例 #1
0
        public string WriteValue(string key, string value)
        {
            var status = "Error";

            try
            {
                if (ValueExists(key))
                {
                    this.ClearValue(key);
                }

                var ls = new LocalStorage();
                ls.KeyString   = key;
                ls.ValueString = value;

                db.LocalStorage.Add(ls);
                db.SaveChanges();
                status = "OK";
            }
            catch (Exception e)
            {
                status = e.Message;
            }

            return(status);
        }
コード例 #2
0
        public void Execute(object parameter)
        {
            var noteParameter = parameter as dynamic;

            if (noteParameter == null)
            {
                return;
            }

            System.Guid noteId = noteParameter?.InkId;

            switch (noteParameter.Type)
            {
            case "Ink":
                using (var db = new LocalStorageContext())
                {
                    var ink = db.Memes.Remove(db.Memes.Find(noteId));
                    db.SaveChanges();
                }

                break;

            case "Bookmark":
                using (var db = new LocalStorageContext())
                {
                    var ink = db.Memes.Remove(db.Memes.Find(noteId));
                    db.SaveChanges();
                }

                break;
            }
        }
コード例 #3
0
        public void Execute(object parameter)
        {
            var     episodeWithState = parameter as EpisodeWithState;
            Episode episode          = episodeWithState?.Episode;

            if (episode == null)
            {
                episode = parameter as Episode;
            }

            if (episode == null)
            {
                return;
            }

            using (var db = new LocalStorageContext())
            {
                foreach (Favorite favEntity in db.Favorites)
                {
                    if (favEntity.EpisodeId == episode.Id)
                    {
                        db.Favorites.Remove(favEntity);
                        break;
                    }
                }

                db.SaveChanges();
            }
        }
コード例 #4
0
        private void SwipeDelete_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
        {
            dynamic output = args.SwipeControl.DataContext;

            System.Guid inkId = output.InkId;

            switch (output.Type)
            {
            case "Ink":
                using (var db = new LocalStorageContext())
                {
                    var ink = db.Memes.Remove(db.Memes.Find(inkId));
                    db.SaveChanges();

                    ReLoadNotes();
                }

                break;

            case "Bookmark":
                using (var db = new LocalStorageContext())
                {
                    var ink = db.Memes.Remove(db.Memes.Find(inkId));
                    db.SaveChanges();

                    ReLoadNotes();
                }

                break;
            }
        }
コード例 #5
0
        private void AppBarButton_Click(object sender, RoutedEventArgs e)
        {
            dynamic output = (sender as AppBarButton).DataContext;

            System.Guid inkId = output.InkId;

            switch (output.Type)
            {
            case "Ink":
                using (var db = new LocalStorageContext())
                {
                    var ink = db.Memes.Remove(db.Memes.Find(inkId));
                    db.SaveChanges();

                    ReLoadNotes();
                }

                break;

            case "Bookmark":
                using (var db = new LocalStorageContext())
                {
                    var ink = db.Memes.Remove(db.Memes.Find(inkId));
                    db.SaveChanges();

                    ReLoadNotes();
                }

                break;
            }
        }
コード例 #6
0
ファイル: InkNote.xaml.cs プロジェクト: alexpisquared/UWP
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            if (_editingExisting)
            {
                using (var db = new LocalStorageContext())
                {
                    db.Memes.Remove(_inkNote);
                    db.SaveChanges();

                    if (_data != null)
                    {
                        db.MemeData.Remove(_data);
                        db.SaveChanges();
                    }
                }
            }
        }
コード例 #7
0
 public void FavoriteCurrentEpisode()
 {
     using (var db = new LocalStorageContext())
     {
         db.Favorites.Add(new Favorite(CurrentEpisode));
         db.SaveChanges();
     }
 }
コード例 #8
0
        public void Execute(object parameter)
        {
            if (parameter == null || (parameter as Episode) == null)
            {
                return;
            }

            using (var db = new LocalStorageContext())
            {
                db.Favorites.Add(new Favorite(parameter as Episode));
                db.SaveChanges();
            }
        }
コード例 #9
0
        public async void RemoveFavoritedEpisode(Episode episode)
        {
            using (var db = new LocalStorageContext())
            {
                foreach (Favorite favEntity in db.Favorites)
                {
                    if (episode == null)
                    {
                        break;
                    }

                    if (favEntity.EpisodeId == episode.Id)
                    {
                        db.Favorites.Remove(favEntity);
                        break;
                    }
                }

                db.SaveChanges();
            }

            await LoadFavorites();
        }