//public DashboardDetailsCardResponse() //{ //} public static DashboardDetailsCardResponse Build(string userId, Dictionary <string, ConfigModelDeck> dictDecks, Card c, Dictionary <string, IDeck> decks, KeyValuePair <string, CardRequiredInfoByDeck>[] decksInfo, UtilColors utilColors) { var ret = new DashboardDetailsCardResponse(); var missing = decksInfo.Where(i => decks.ContainsKey(i.Key) == false).ToArray(); if (missing.Any()) { Log.Error("User {userId} Error in DashboardDetailsCardResponse: Cannot find these decks: <{ids}>. Original ids: <{ids2}>", userId, string.Join(",", missing.Select(x => x.Key)), string.Join(",", missing.Select(x => x.Value.DeckId))); } ret.InfoByDeck = decksInfo .Where(i => missing.Any(x => x.Key == i.Key) == false) .Select(i => new DashboardDetailsCardDto { DeckId = i.Key, DeckName = decks[i.Key].Name, NbMain = i.Value.ByCard[c.name].NbRequiredMain, NbSideboard = i.Value.ByCard[c.name].NbRequiredSideboard, DeckColor = utilColors.FromDeck(decks[i.Key]), DeckDateCreated = dictDecks[i.Key].DateCreatedUtc, DeckScraperTypeId = decks[i.Key].ScraperType.Id, }) .ToArray(); return(ret); }
public string Convert(ConfigModelRawDeck sourceMember, ResolutionContext context) { if (sourceMember?.CardsMain == null) { return(""); } try { var cards = sourceMember.CardsMainWithCommander.Keys//.Union(sourceMember.CardsSideboard.Keys) .Where(i => dictAllCards.ContainsKey(i)) .Select(i => new DeckCard(new CardWithAmount(dictAllCards[i]), DeckCardZoneEnum.Deck)) .ToArray(); var deck = new Deck(sourceMember.Name, null, cards); return(utilColors.FromDeck(deck)); } catch (Exception ex) { Log.Error(ex, $"ERROR: whats null? <{sourceMember}> <{sourceMember?.CardsMain}> <{sourceMember?.CardsMain?.Keys}>"); return(""); } }