public void MapMagicCardTesting_ModelEntity()
        {
            // Arrange
            var testCard = new Model.MagicCard
            {
                Id       = 1,
                UserId   = 1,
                Name     = "Llanowar Elves",
                Color    = "Green",
                CMC      = 1,
                Type     = "Creature - Elf Druid",
                Rarity   = "Common",
                Booster  = "Dominaria",
                Image    = "TestImageLink",
                Location = "Binder"
            };

            // Act
            var entityCard = Mapper.Map(testCard);

            // Assert
            Assert.Equal(1, entityCard.Id);
            Assert.Equal(1, entityCard.UserId);
            Assert.Equal("Llanowar Elves", entityCard.Name);
            Assert.Equal("Green", entityCard.Color);
            Assert.Equal(1, entityCard.CMC);
            Assert.Equal("Creature - Elf Druid", entityCard.Type);
            Assert.Equal("Common", entityCard.Rarity);
            Assert.Equal("Dominaria", entityCard.Booster);
            Assert.Equal("TestImageLink", entityCard.Image);
            Assert.Equal("Binder", entityCard.Location);
        }
示例#2
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());
     }
 }
示例#3
0
        public void PostMagicCard(Lib.MagicCard card)
        {
            var e_card = Mapper.Map(card);

            _context.MagicCard.Add(e_card);
            _context.SaveChanges();
        }
示例#4
0
        public void PutMagicCard(Lib.MagicCard card)
        {
            var e_card = Mapper.Map(card);
            var group  = _context.MagicCard.First(g => g.Id == card.Id);

            _context.Entry(group).CurrentValues.SetValues(card);
            _context.SaveChanges();
        }
示例#5
0
        public IActionResult OtherMagicCardDetails([FromRoute] int id = 1)
        {
            TempData["id"] = id;
            Lib.MagicCard card = _repo.GetMagicCard(id);
            EditLocation  l    = new EditLocation()
            {
                Card = card
            };

            return(View(l));
        }
示例#6
0
 public static Entities.MagicCard Map(Lib.MagicCard c)
 {
     Entities.MagicCard card = new Entities.MagicCard()
     {
         Id       = c.Id,
         UserId   = c.UserId,
         Name     = c.Name,
         Color    = c.Color,
         CMC      = c.CMC,
         Type     = c.Type,
         Rarity   = c.Rarity,
         Booster  = c.Booster,
         Image    = c.Image,
         Location = c.Location
     };
     return(card);
 }