//[HttpGet] //[Authorize(Roles = "player,admin")] //public ActionResult DeckDetails(int id) //{ // /// Objekt für den Deckbuilder // /// bestehend aus Cards IM Deck // /// und aus Cards FÜR das Deck // var model = new Deckbuilder(); // /// Karten IM Deck // var dbDeckCards = DeckManager.GetDeckCardsById(id); // if (dbDeckCards != null) // { // foreach (var cc in dbDeckCards) // { // Card card = new Card(); // card.ID = cc.ID; // card.Attack = cc.Attack; // card.Name = cc.Name; // card.Life = cc.Life; // card.Mana = cc.Mana; // //card.Type = UserManager.CardTypeNames[cc.fkCardType ?? 0]; // model.Deck.Add(card); // } // } // var dbUserCards = CardManager.GetAllCardsForDeck(User.Identity.Name, id); // if (dbUserCards != null) // { // foreach (var cc in dbUserCards) // { // Card card = new Card(); // card.ID = cc.ID; // card.Attack = cc.Attack; // card.Name = cc.Name; // card.Life = cc.Life; // card.Mana = cc.Mana; // //card.Type = UserManager.CardTypeNames[cc.fkCardType ?? 0]; // model.Collection.Add(card); // } // } // return View(model); //} /// <summary> /// ActionResult EditDeck fürs Editieren meine gewählten Decks /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult EditDeck(int id) { /// Erstelle ein Objekt das während der Bearbeitung /// die karten beinhaltet Deckbuilder db = new Deckbuilder(); // speichere dort auch die ID des Decks db.ID = id; var dbDeckCards = DeckManager.GetDeckCardsById(id); foreach (var cc in dbDeckCards) { Web.Models.Card card = new Web.Models.Card(); card.ID = cc.ID; card.Attack = cc.Attack; card.Name = cc.Name; card.Life = cc.Life; card.Mana = cc.Mana; card.Pic = cc.Pic; //card.Type = UserManager.CardTypeNames[cc.fkCardType ?? 0]; //card.Type = card.Type == "Minion" ? "M" : card.Type == "Spell" ? "S" : "W"; db.Deck.Add(card); } var dbCardList = UserManager.GetAllCardsByEmail(User.Identity.Name); foreach (var cc in dbCardList) { Web.Models.Card card = new Web.Models.Card(); card.ID = cc.ID; card.Attack = cc.Attack; card.Name = cc.Name; card.Life = cc.Life; card.Mana = cc.Mana; card.Pic = cc.Pic; //card.Type = UserManager.CardTypeNames[cc.fkCardType ?? 0]; //card.Type = card.Type == "Minion" ? "M" : card.Type == "Spell" ? "S" : "W"; db.Collection.Add(card); } foreach (var deckCard in db.Deck) { int idx = db.Collection.FindIndex(i => i.Name == deckCard.Name); db.Collection.RemoveAt(idx); } TempData["DeckBuilder"] = db; return(View(db)); }
/// <summary> /// Verändert das DeckBuilder Objekt im TempData /// ACHTUNG es wurde NOCH NICHTS gespeichert /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult RemoveCardFromDeck(int id) { /// id ist eigentlich INDEX Web.Models.Deckbuilder db = new Web.Models.Deckbuilder(); db = (Deckbuilder)TempData["DeckBuilder"]; Web.Models.Card card = db.Deck[id]; db.Deck.RemoveAt(id); db.Collection.Add(card); TempData["DeckBuilder"] = db; return(View("EditDeck", db)); }
/// <summary> /// Verändert das DeckBuilder Objekt im TempData /// ACHTUNG es wurde NOCH NICHTS gespeichert /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult AddCardToDeck(int id) { /// Übergabeparameter id ist eigentlich INDEX!!! Wichtig ...... Web.Models.Deckbuilder db = new Web.Models.Deckbuilder(); db = (Deckbuilder)TempData["DeckBuilder"]; Web.Models.Card card = db.Collection[id]; db.Collection.RemoveAt(id); db.Deck.Add(card); TempData["DeckBuilder"] = db; return(View("EditDeck", db)); }