Ejemplo n.º 1
0
 async void FavoriteList_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Move)
     {
         return;
     }
     try
     {
         CachedClient.UpdateCachedUserFavoriteVolumes(FavoriteList);
         if (e.NewItems != null)
         {
             foreach (FavourVolume vol in e.NewItems)
             {
                 if (String.IsNullOrEmpty(vol.FavId))
                 {
                     await LightKindomHtmlClient.AddUserFavoriteVolume(vol.VolumeId);
                 }
             }
         }
         if (e.OldItems != null)
         {
             foreach (FavourVolume vol in e.OldItems)
             {
                 if (!String.IsNullOrEmpty(vol.FavId))
                 {
                     await LightKindomHtmlClient.DeleteUserFavorite(vol.FavId);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         Debug.WriteLine("Error : Failed to Sync User Favorite : " + exception.Message);
     }
 }
Ejemplo n.º 2
0
        public async Task <bool> RemoveUserFavriteAsync(string favId)
        {
            var vol = FavoriteList.FirstOrDefault(fav => fav.FavId == favId);

            if (String.IsNullOrEmpty(favId) || vol == null)
            {
                return(false);
            }
            try
            {
                await LightKindomHtmlClient.DeleteUserFavorite(favId);

                FavoriteList.Remove(vol);
                CachedClient.UpdateCachedUserFavoriteVolumes(FavoriteList);
                return(true);
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Error : Failed to Remove User Favorite : " + exception.Message);
            }
            return(false);
        }
Ejemplo n.º 3
0
        public async Task <bool> AddUserFavriteAsync(Volume vol, string seriesTitle = null)
        {
            if (FavoriteList == null)
            {
                return(false);
            }
            if (FavoriteList.Any(fav => fav.VolumeId == vol.Id))
            {
                return(true);
            }
            try
            {
                var result = await LightKindomHtmlClient.AddUserFavoriteVolume(vol.Id);

                if (!result)
                {
                    return(false);
                }
                FavourVolume favol = new FavourVolume
                {
                    VolumeId      = vol.Id,
                    FavId         = null,
                    VolumeNo      = vol.VolumeNo.ToString(),
                    CoverImageUri = vol.CoverImageUri,
                    Description   = vol.Description,
                    VolumeTitle   = vol.Title,
                    SeriesTitle   = seriesTitle,
                    FavTime       = DateTime.Now.AddSeconds(-5)
                };
                FavoriteList.Add(favol);
                CachedClient.UpdateCachedUserFavoriteVolumes(FavoriteList);
                return(true);
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Error : Failed to Add User Favorite : " + exception.Message);
            }
            return(false);
        }
Ejemplo n.º 4
0
        public async Task <bool> RemoveUserFavriteAsync(string[] favIds)
        {
            try
            {
                await LightKindomHtmlClient.DeleteUserFavorite(favIds);

                foreach (var favId in favIds)
                {
                    var f = FavoriteList.FirstOrDefault(fa => fa.FavId == favId);
                    if (f != null)
                    {
                        FavoriteList.Remove(f);
                    }
                }
                CachedClient.UpdateCachedUserFavoriteVolumes(FavoriteList);
                return(true);
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Error : Failed to Remove User Favorite : " + exception.Message);
            }
            return(false);
        }