public static CardVm Map(CardDm dm) { var vm = new CardVm { Id = dm.Id, Name = dm.Name, Cmc = dm.Cmc, Cost = dm.Cost, Legality = new CardLegalityVm { Commander = dm.Legality.Commander, Legacy = dm.Legality.Legacy, Modern = dm.Legality.Modern, Standard = dm.Legality.Standard, Vintage = dm.Legality.Vintage }, Power = dm.Power, Toughness = dm.Toughness, RulesText = dm.RulesText, StoreUrl = dm.StoreUrl, Url = dm.Url, Types = dm.Types, SubTypes = dm.SubTypes, Colors = dm.Colors, Sets = MapSets(dm.Sets).ToList() }; return(vm); }
public static CardDm Map(Card em) { var dm = new CardDm { Id = em.CardId, Name = em.CardName, Cmc = em.ConvertedManaCost, Cost = em.Cost, Legality = new CardLegalityDm { Commander = em.Commander == "legal", Legacy = em.Legacy == "legal", Modern = em.Modern == "legal", Standard = em.Standard == "legal", Vintage = em.Vintage == "legal" }, Power = em.Power, Toughness = em.Toughness, RulesText = em.RulesText, StoreUrl = em.StoreUrl, Url = em.Url, Types = em.Types.Replace(" ", "").Split(',').ToList(), SubTypes = em.SubTypes.Replace(" ", "").Split(',').ToList(), Colors = em.Colors.Replace(" ", "").Split(',').ToList(), Sets = MapSets(em.CardSets.ToList()), Tags = TagMapper.Map(em.CardTags.Select(ct => ct.Tag)).ToList() }; return(dm); }
private static void DeleteCard(DeckDm deck, CardDm card) { using (var db = new MtgEntities()) { var deckCard = db.DeckCards.Single(dc => dc.DeckId == deck.Id && dc.CardId == card.Id); db.DeckCards.Remove(deckCard); db.SaveChanges(); } }
private static DeckCard CardMap(int deckId, CardDm card) { return(new DeckCard { DeckCardsId = 0, DeckId = deckId, CardId = card.Id, Quantity = card.Quantity }); }
private static void InsertCard(string deckName, CardDm card) { var deck = GetDeck(deckName); var deckCard = new DeckCard { DeckCardsId = 0, DeckId = deck.Id, CardId = card.Id }; using (var db = new MtgEntities()) { db.DeckCards.Add(deckCard); db.SaveChanges(); } }