Exemplo n.º 1
0
        public void AddNewDeck(string username, Deck deck)
        {
            using (var context = new HearthChartContext())
            {
                var account = (from acc in context.Accounts
                               where acc.Username == username
                               select acc).FirstOrDefault();

                if (account != null)
                {
                    account.Decks.Add(deck);
                    context.SaveChanges();
                }

            }
        }
Exemplo n.º 2
0
        public ActionResult New(DeckModel model)
        {
            if (ModelState.IsValid)
            {
                var deck = new Deck()
                {
                    Name = model.Name,
                    DeckClass = model.DeckClass,
                    Wins = 0,
                    Losses = 0
                };

                _repository.AddNewDeck(User.Identity.Name, deck);

                TempData["NotifyCss"] = "notify-success";
                TempData["NotifyMessage"] = "Deck successfully created.";
                return RedirectToAction("Index","Decks", new { username = User.Identity.Name});
            }
            return View();
        }