public void SetStarred(SetViewModel set, bool starred, Action completed, Action <Exception> errorHandler) { if (starred == set.Starred) { return; } api.SetStarred( set.ID, starred, delegate { cache.SetStarred(set.ID, starred); if (starred) { FavouriteSets.Add(set); } else { FavouriteSets.Remove(set); } set.Starred = starred; completed(); }, errorHandler, new CancellationToken()); }
public void Delete(SetViewModel set, Action success, Action <Exception> errorHandler) { Action completion = delegate { MySets.Remove(s => s.ID == set.ID); FavouriteSets.Remove(s => s.ID == set.ID); foreach (var g in Groups) { g.Sets.Remove(s => s.ID == set.ID); } cache.RemoveSet(set.ID); success(); }; api.DeleteSet( set.ID, completion, err => { if (err is ItemDeletedException) { completion(); // This case can hardly be considered an error. } else { errorHandler(err); } }, new CancellationToken()); }