Esempio n. 1
0
        public async Task InsertDeleteFavorite(MangaOL.Models.Manga item, bool isFavorite)
        {
            var listMangas = MainPageVM.Mangas.Where(t => t.UriManga == item.UriManga).ToList();
            var listHistorys = MainPageVM.MangasH.Where(t => t.UriManga == item.UriManga).ToList();
            if (listHistorys != null)
            {
                foreach (var itemHistory in listHistorys)
                {
                    itemHistory.IsFavorite = !isFavorite;
                }
            }
            if (listMangas != null)
            {
                foreach (var itemManga in listMangas)
                {
                    itemManga.IsFavorite = !isFavorite;
                }
            }

            if (isFavorite)
            {
                MangaCore.Sqlite.Models.SqlMangaFavorite i = App.dbHelper.Select<MangaCore.Sqlite.Models.SqlMangaFavorite>(t => t.Url == item.UriManga);
                App.dbHelper.Delete<MangaCore.Sqlite.Models.SqlMangaFavorite>(i);
                //MainPageVM.MangaFavorite.Remove(MainPageVM.MangaFavorite.FirstOrDefault(t => t.UriManga == item.UriManga));
                App.MangaFavorite.Remove(App.MangaFavorite.FirstOrDefault(t => t.UriManga == item.UriManga));
            }
            else
            {
                var jsonDetail = await Config.GetDetail(item.UriManga);
                if (jsonDetail.status)
                {
                    App.dbHelper.Insert<MangaCore.Sqlite.Models.SqlMangaFavorite>(new MangaCore.Sqlite.Models.SqlMangaFavorite(App.NewSever, item.NameManga, item.UriCover, item.UriManga, DateTime.Now.ToString(MangaCore.Comon.FormatDateTime), jsonDetail.data.listChap.Count, true));
                    var itemManga = new Manga(item.UriManga, item.NameManga, item.UriCover, "", App.NewSever, DateTime.Now.ToString(MangaCore.Comon.FormatDateTime), 0);
                    itemManga.IsNotication = true;
                    App.MangaFavorite.Insert(0, itemManga);
                }
            }

        }
Esempio n. 2
0
 internal void InsertDeleteFavorite(MangaOL.Models.Detail item)
 {
     if (item.IsFavorite)
     {
         MangaCore.Sqlite.Models.SqlMangaFavorite i = App.dbHelper.Select<MangaCore.Sqlite.Models.SqlMangaFavorite>(t => t.Url == item.UrlManga);
         App.dbHelper.Delete<MangaCore.Sqlite.Models.SqlMangaFavorite>(i);
         App.MangaFavorite.Remove(App.MangaFavorite.FirstOrDefault(t => t.UriManga == item.UrlManga));
     }
     else
     {
         App.dbHelper.Insert<MangaCore.Sqlite.Models.SqlMangaFavorite>(new MangaCore.Sqlite.Models.SqlMangaFavorite(App.NewSever, item.NameManga, item.UrlCover, item.UrlManga, DateTime.Now.ToString(MangaCore.Comon.FormatDateTime), this.Chapers.Count, true));
         var itemManga = new Manga(item.UrlManga, item.NameManga, item.UrlCover, "", App.NewSever, DateTime.Now.ToString(MangaCore.Comon.FormatDateTime), 0);
         itemManga.IsNotication = true;
         App.MangaFavorite.Insert(0, itemManga);
     }
     this.ItemDetail.IsFavorite = !item.IsFavorite;
 }
Esempio n. 3
0
        private void LoadMangaFavorite()
        {
            if (this.isLoadMangaFavorite == LoadState.None)
            {
                this.isLoadMangaFavorite = LoadState.Loading;
                List<SqlMangaFavorite> list = App.dbHelper.Select<SqlMangaFavorite>().OrderByDescending(t => t.DateTimeCreate).ToList();
                App.MangaFavorite.Clear();
                for (int i = App.MangaFavorite.Count; i < list.Count; i++)
                {
                    SqlMangaFavorite sqlMangaFavorite = list[i];
                    var item = new Manga(sqlMangaFavorite.Url, sqlMangaFavorite.NameManga, sqlMangaFavorite.UrlCover, "", sqlMangaFavorite.Sever, sqlMangaFavorite.DateTimeCreate, sqlMangaFavorite.ID);

                    item.IsNotication = sqlMangaFavorite.IsNotication;
                    App.MangaFavorite.Add(item);
                }
                if (App.MangaFavorite.Count > 0)
                {
                    this.isLoadMangaFavorite = LoadState.Loaded;
                }
                else
                {
                    this.isLoadMangaFavorite = LoadState.Loading;
                }
            }
        }
Esempio n. 4
0
 private void ReadManga(Manga manga)
 {
     App.IsTpyeNavigated = TypeNavigaed.Manga;
     PhoneApplicationService.Current.State["param"] = manga;
     this.NavigationService.Navigate(new Uri("/Views/DetailPage.xaml", UriKind.RelativeOrAbsolute));
 }