예제 #1
0
        private async void Deletebtn_Clicked(object sender, EventArgs e)
        {
            string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PostsQLite.db3");
            var    postdb = new PostDatabase(dbPath);
            await postdb.DeleteNoteAsync(article);

            await Navigation.PopAsync();
        }
예제 #2
0
        public PostViewModel(AlbumModel albumSelected)
        {
            postDatabase = App.Container.Resolve <PostDatabase>();
            postApi      = App.Container.Resolve <PostApi>();

            albumModel = albumSelected;

            GetDatabase();
        }
        GetSavedPostsAsync()
        {
            string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PostsQLite.db3");

            var db = new PostDatabase(dbPath);

            try
            {
                //Activity indicator visibility on
                activity_indicator.IsVisible = true;
                activity_indicator.IsRunning = true;
                refreshcon.IsVisible         = false;
                savedPosts.IsVisible         = false;


                var tr = await db.GetPostsAsync();

                //After deserializing , we store our data in the List called ObservableCollection


                //Then finally we attach the List to the ListView. Seems Simple :)
                savedPosts.ItemsSource = tr;


                //We check the number of PostModelItem in the Observable Collection
                int i = tr.Count();
                if (i > 0)
                {
                    //If they are greater than Zero we stop the activity indicator
                    activity_indicator.IsRunning = false;
                    savedPosts.IsVisible         = true;
                }
                else
                {
                    savedPosts.IsVisible         = false;
                    activity_indicator.IsVisible = false;
                    refreshcon.IsVisible         = true;
                    infolabel.Text = "No saved posts found";
                }

                //Here we Wrap  the size of the ListView according to the number of PostModelItem which have been retrieved
                i = (tr.Count() * heightRowsList);
                activity_indicator.HeightRequest = i;
            }
            catch (Exception ey)
            {
                Debug.WriteLine("" + ey);
            }
        }
예제 #4
0
        private async void Savebtn_Clicked(object sender, EventArgs e)
        {
            string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PostsQLite.db3");

            var postdb = new PostDatabase(dbPath);


            if (await postdb.SavePostAsync(article) != 0)
            {
                savebtn.IsEnabled = false;
            }
            else
            {
                await DisplayAlert("Error", "Error saving", "OK");

                savebtn.IsEnabled = true;
            }
        }
예제 #5
0
        private async void ShowPost(object opost)
        {
            savebtn.IsEnabled = false;


            var singlepost = opost as PostModelItem;

            article = new Post()
            {
                ID     = singlepost._id,
                Author = singlepost.Author,
                Body   = singlepost.Body,
                Date   = singlepost.Date,
                Intro  = singlepost.Intro,
                Title  = singlepost.Title
            };


            MainPageContent.Title = singlepost.Title;

            var htmlSource = new HtmlWebViewSource
            {
                Html = @singlepost.Body
            };

            browser.Source = htmlSource;

            string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PostsQLite.db3");

            var postdb = new PostDatabase(dbPath);

            var gpost = await postdb.GetPostAsync(article.ID);

            if (gpost == null)
            {
                savebtn.IsEnabled = true;
            }
            else
            {
                await DisplayAlert("Warning", "Post Already Saved", "OK");

                savebtn.IsEnabled = false;
            }
        }
예제 #6
0
 public virtual string  CreatePost(PostDatabase db, string post)
 {
     return(db.Add(post));
 }
예제 #7
0
 public override string  CreatePost(PostDatabase db, string post)
 {
     return(db.AddLinkPost(post));
 }