public void DeleteItem(IVideoItem item) { IVideoItem el = ChannelItems.FirstOrDefault(x => x.ID == item.ID); if (el != null) { ChannelItems.Remove(el); } }
public void AddToStateList(object state, IVideoItem item) { if (state is WatchState) { var st = (WatchState)state; switch (st) { case WatchState.Watched: if (!watchedList.Select(x => x.ID).Contains(item.ID)) { watchedList.Add(item); if (SelectedState != null && SelectedState.State as WatchState? == st) { AddNewItem(item); } if (!watchedListIds.Contains(item.ID)) { watchedListIds.Add(item.ID); } } break; case WatchState.Planned: if (!plannedList.Select(x => x.ID).Contains(item.ID)) { plannedList.Add(item); if (SelectedState != null && SelectedState.State as WatchState? == st) { AddNewItem(item); } if (!plannedListIds.Contains(item.ID)) { plannedListIds.Add(item.ID); } IVideoItem vi = watchedList.FirstOrDefault(x => x.ID == item.ID); if (vi != null) { watchedList.Remove(vi); if (watchedListIds.Contains(item.ID)) { watchedListIds.Remove(item.ID); } } if (SelectedState != null && SelectedState.State as WatchState? == WatchState.Watched) { DeleteItem(item); } } break; case WatchState.Notset: IVideoItem vim = plannedList.FirstOrDefault(x => x.ID == item.ID); if (vim != null) { plannedList.Remove(vim); if (plannedListIds.Contains(item.ID)) { plannedListIds.Remove(item.ID); } } // if (SelectedState != null && SelectedState.State as WatchState? == WatchState.Planned) // { // DeleteItem(item); // } break; } } else if (state is SyncState) { var st = (SyncState)state; switch (st) { case SyncState.Added: if (!addedList.Select(x => x.ID).Contains(item.ID)) { addedList.Add(item); if (!addedListIds.Contains(item.ID)) { addedListIds.Add(item.ID); if (SelectedState != null && SelectedState.State as SyncState? == st) { if (!ChannelItems.Select(x => x.ID).Contains(item.ID)) { ChannelItems.Add(item); } } } } break; case SyncState.Notset: IVideoItem vi = addedList.FirstOrDefault(x => x.ID == item.ID); if (vi != null) { addedList.Remove(vi); if (addedListIds.Contains(item.ID)) { addedListIds.Remove(item.ID); if (SelectedState != null && SelectedState.State as SyncState? == SyncState.Added) { IVideoItem ite = ChannelItems.FirstOrDefault(x => x.ID == item.ID); if (ite != null) { ChannelItems.Remove(ite); } } } } break; } } }