コード例 #1
0
        /// <summary>
        /// Lists the decks that belong to the user.
        /// </summary>
        /// <returns>The view.</returns>
        public ActionResult List()
        {
            if (!Models.AccountUtils.isLoggedIn(this))
            {
                return(RedirectToAction("LogIn", "Account"));
            }

            var loginHash = Request.Cookies["loginHash"].Value;
            var accountId = Models.AccountUtils.GetAccountID(loginHash);

            if (accountId < 0)
            {
                return(RedirectToAction("LogOut", "Account"));
            }

            var deckDB = new Models.DecksDataContext();

            var decks = from d in deckDB.Decks
                        where d.OwnerId == accountId
                        select d;

            var model = new Models.DeckListViewModel();

            model.deckList = new List <Models.Deck>();

            foreach (var deck in decks)
            {
                model.deckList.Add(deck);
            }

            return(View(model));
        }
コード例 #2
0
ファイル: DeckController.cs プロジェクト: Okiesmokie/mtgcards
        /// <summary>
        /// Lists the decks that belong to the user.
        /// </summary>
        /// <returns>The view.</returns>
        public ActionResult List()
        {
            if(!Models.AccountUtils.isLoggedIn(this)) return RedirectToAction("LogIn", "Account");

            var loginHash = Request.Cookies["loginHash"].Value;
            var accountId = Models.AccountUtils.GetAccountID(loginHash);

            if(accountId < 0) return RedirectToAction("LogOut", "Account");

            var deckDB = new Models.DecksDataContext();

            var decks = from d in deckDB.Decks
                        where d.OwnerId == accountId
                        select d;

            var model = new Models.DeckListViewModel();
            model.deckList = new List<Models.Deck>();

            foreach(var deck in decks) {
                model.deckList.Add(deck);
            }

            return View(model);
        }