Exemple #1
0
 // Post a new Magic card to the database
 public IActionResult PostMagicCard(AddMagicCardViewModels c, IFormCollection form)
 {
     try
     {
         Lib.MagicCard ca   = _repo.GetMagicCard(c.id);
         Lib.MagicCard card = new Lib.MagicCard()
         {
             Booster  = ca.Booster,
             CMC      = ca.CMC,
             Color    = ca.Color,
             Image    = ca.Image,
             Location = c.Location,
             Name     = ca.Name,
             Rarity   = ca.Rarity,
             Type     = ca.Type,
             UserId   = Convert.ToInt32(HttpContext.Session.GetInt32("Id"))
         };
         _repo.PostMagicCard(card);
         var Cards = _repo.GetMagicCards(HttpContext.Session.GetInt32("Id"));
         if (Cards.Count() > 0)
         {
             ViewBag.MTG = "yes";
         }
         var Cards2 = _repo.GetBaseballCards(HttpContext.Session.GetInt32("Id"));
         if (Cards2.Count() > 0)
         {
             ViewBag.Baseball = "yes";
         }
         return(View("MyCollections"));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemple #2
0
        public IActionResult AddCardAction(CardTypeViewModel c, IFormCollection form)
        {
            ViewBag.UserId = HttpContext.Session.GetString("Id");
            AddMagicCardViewModels model = new AddMagicCardViewModels();

            if (c.cardType == "MTG")
            {
                var Cards = _repo.GetMagicCards(-1);
                model.MagicCards = Cards.ToList();
                return(View("CreateMagicCard", model));
            }
            else
            {
                var Cards = _repo.GetBaseballCards(-1);
                return(View("CreateBaseballCard", model));
            }
        }