private void MoveCardAction(object obj) { BasicCardDTO card = (BasicCardDTO)obj; ReadCard oldCard = null; ReadCardList oldList = null; if (card != null) { foreach (var vm in CardListViewModels) { oldCard = vm.CardList.Cards.FirstOrDefault(c => c.CardId == card.CardId); oldList = vm.CardList; if (oldCard != null) { break; } } oldList.Cards.Remove(oldCard); CardListViewModel newList = CardListViewModels.FirstOrDefault(c => c.CardList.ListId == card.ListId); if (newList != null) { oldCard.ListId = card.ListId; newList.CardList.Cards.Add(oldCard); } } }
public async void OnMoveCard(MoveCard moveCard) { bool result = await CardService.MoveCard(ActiveUser.Instance.LoggedUser.Token, moveCard.CardId, moveCard.NewListId); if (!result) { ShowMessageBox(null, "Error moving card."); return; } CardListViewModel oldListVM = CardListViewModels.FirstOrDefault(listVM => listVM.CardList.ListId == moveCard.OldListId); if (oldListVM == null) { return; } ReadCard oldCard = oldListVM.CardList.Cards.FirstOrDefault(card => card.CardId == moveCard.CardId); if (oldCard == null) { return; } oldListVM.CardList.Cards.Remove(oldCard); oldCard.ListId = moveCard.NewListId; CardListViewModel newListVM = CardListViewModels.FirstOrDefault(listVM => listVM.CardList.ListId == moveCard.NewListId); if (newListVM == null) { return; } newListVM.CardList.Cards.Add(oldCard); }
private void DeleteCardListAction(object obj) { int cardListId = (int)obj; CardListViewModel vm = CardListViewModels.FirstOrDefault(x => x.CardList.ListId == cardListId); if (vm != null) { CardListViewModels.Remove(vm); } }
public async void OnDeleteCardList(ReadCardList cardList) { if (ActiveUser.IsActive == true) { bool succ = await CardListService.DeleteCardList(ActiveUser.Instance.LoggedUser.Token, cardList.ListId); if (succ == true) { CardListViewModel vm = CardListViewModels.FirstOrDefault(x => x.CardList.ListId == cardList.ListId); CardListViewModels.Remove(vm); vm.DestroyPanel(); ShowMessageBox(null, "Card list deleted."); } else { ShowMessageBox(null, "Error deleting card list."); } } else { ShowMessageBox(null, "Error getting user."); } }