public ActionResult AddCard(AddCardToDeckViewModel model) { Deck dd = _context.Decks.Single(d => d.DeckId == model.Deck.DeckId); dd.Cards.Add(_context.Cards.Single(c => c.CardId == model.CardId)); _context.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddCardTo(Deck deck) { Deck dd = _context.Decks.ToList().Where(d => d.DeckId == deck.DeckId).Single(); List <Card> cd = _context.Cards.ToList().Where(c => !dd.Cards.Contains(c)).Where(c => c.CardClass == dd.DeckClass || c.CardClass == "Neutral").ToList(); AddCardToDeckViewModel model = new AddCardToDeckViewModel(dd, cd); return(View(model)); }