public RedirectToActionResult DownloadDeck(int deckId)
        {
            var deck     = _deckRepository.Decks.Where(d => d.DeckId == deckId).FirstOrDefault();
            var fileName = deck.DeckName + ".txt";
            //var filePath = Path.Combine("wwwroot","DeckText", fileName);
            //string vPath = filePath.Replace(@"C:\Users\chunk\OneDrive\Documents\ChronoclashWebsite\CC Code\ChronoClashDatabase\ChronoClashDeckBuilder\ChronoClashDeckBuilder\wwwroot", "~").Replace(@"\", "/");
            string deckStr = "";


            deckStr += ("//Main Deck\n");
            foreach (KeyValuePair <string, int> entry in CurDeck.GetCardDictionary(deck.MainDeckCards))
            {
                deckStr += (entry.Value + " (" + entry.Key + ")\n");
            }
            deckStr += ("//Extra Deck\n");
            foreach (KeyValuePair <string, int> entry in CurDeck.GetCardDictionary(deck.ExtraDeckCards))
            {
                deckStr += (entry.Value + " (" + entry.Key + ")\n");
            }


            Response.Clear();
            Response.ContentType = "application/force-download";
            Response.Headers.Add("content-disposition", "attachment; filename =" + fileName);
            Response.WriteAsync(deckStr);
            return(RedirectToAction("Deck", deckId));
        }
예제 #2
0
 public DeckBuilderController(ICardRepository repo, IDeckRepository deckRepo, CurDeck deckService, UserManager <IdentityUser> userManager, SignInManager <IdentityUser> signInManager)
 {
     repository     = repo;
     deckRepository = deckRepo;
     curDeck        = deckService;
     _userManager   = userManager;
     _signInManager = signInManager;
 }
        public string UntapDeck(int deckId)
        {
            var    deck    = _deckRepository.Decks.Where(d => d.DeckId == deckId).FirstOrDefault();
            string deckStr = "";


            deckStr += ("//Main Deck\n");
            foreach (KeyValuePair <string, int> entry in CurDeck.GetCardDictionary(deck.MainDeckCards))
            {
                deckStr += (entry.Value + " (" + entry.Key + ")\n");
            }
            deckStr += ("//Extra Deck\n");
            foreach (KeyValuePair <string, int> entry in CurDeck.GetCardDictionary(deck.ExtraDeckCards))
            {
                deckStr += (entry.Value + " (" + entry.Key + ")\n");
            }

            return(deckStr);
        }