public ActionResult AddCard(string add, string remove) { List <CardItem> cards = Session["CardItems"] as List <CardItem>; if (cards == null) { cards = new List <CardItem>(); } if (!string.IsNullOrWhiteSpace(add)) { CardItem temp = cards.FirstOrDefault(x => x.CardID == add); if (temp == null) { MTGClient client = new MTGClient(); Card card = client.GetCard(add); cards.Add(new CardItem() { CardID = card.Id, Name = card.Name, Quantity = 1 }); } else { temp.Quantity++; } Session["CardItems"] = cards; return(RedirectToAction("Edit")); } else if (!string.IsNullOrWhiteSpace(remove)) { CardItem temp = cards.FirstOrDefault(x => x.CardID == remove); if (temp != null) { if (temp.Quantity > 1) { temp.Quantity--; } else { cards.Remove(temp); } } Session["CardItems"] = cards; return(RedirectToAction("Edit")); } else { return(RedirectToAction("Edit")); } }
public void SetImages(Search data) { Dictionary <string, ImageItem> images = new Dictionary <string, ImageItem>(); if (data != null) { foreach (var card in data.Data) { MTGClient client = new MTGClient(); images.Add(card.Id, new ImageItem(card.Id, card.Name, client.GetImageFromCard(card))); } } ViewBag.CardImages = images; }
public void SetImages(Search data) { Dictionary <string, Tuple <string, string> > images = new Dictionary <string, Tuple <string, string> >(); if (data != null) { foreach (var card in data.Data) { MTGClient client = new MTGClient(); images.Add(card.Id, new Tuple <string, string>(client.GetImageFromCard(card), card.ScryfallUri)); } } ViewBag.CardImages = images; }
static void Main(string[] args) { try { MTGClient client = new MTGClient(); client.SearchCards("f:pioneer c=rbu"); } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { Console.ReadKey(); } }
public Search Search() { MTGClient client = new MTGClient(); List <string> querys = new List <string>(); querys.Add($"f:{Format}"); if (!string.IsNullOrWhiteSpace(CardName)) { querys.Add(CardName); } if (!string.IsNullOrWhiteSpace(CardText)) { querys.Add($"o:'{CardText}'"); } string q = string.Join(" ", querys); Data = client.SearchCards(q, Page); return(Data); }