Ejemplo n.º 1
0
        // GET: Reports/WishList
        public ActionResult WishList(int?personId)
        {
            Account account = Session["account"] as Account;

            if (account == null)
            {
                TempData["infoMsg"] = "You must be logged in.";
                return(RedirectToAction("", "Login"));
            }
            if (account.roleCode != "employee")
            {
                throw new HttpException(403, "Access denied");
            }
            List <ViewModels.WishList> wishListItems = new List <ViewModels.WishList>();

            foreach (Wishlist wishList in db.Wishlists.Where(wl => wl.Person.personId == personId))
            {
                ViewModels.WishList wishListItem = new ViewModels.WishList();
                wishListItem.wishlistId = wishList.wishlistId;
                wishListItem.gameId     = wishList.gameId;
                wishListItem.title      = wishList.Game.title;
                if (wishList.Game.GameDetails.Where(gd => gd.phyCopy).SingleOrDefault() != null)
                {
                    wishListItem.phyPrice = wishList.Game.GameDetails.Where(gd => gd.phyCopy).SingleOrDefault().price;
                }
                if (wishList.Game.GameDetails.Where(gd => !gd.phyCopy).SingleOrDefault() != null)
                {
                    wishListItem.downPrice = wishList.Game.GameDetails.Where(gd => !gd.phyCopy).SingleOrDefault().price;
                }
                wishListItems.Add(wishListItem);
            }
            ViewBag.userName = db.People.Find(personId).Account.userName;
            return(View(wishListItems));
        }
Ejemplo n.º 2
0
        // GET: WishList/?userName=userName
        public ActionResult Index(string userName)
        {
            Account account = Session["account"] as Account;

            if (account == null)
            {
                TempData["infoMsg"] = "You must be logged in.";
                return(RedirectToAction("", "Login"));
            }
            if (account.userName != userName)
            {
                if (userName == null)
                {
                    throw new HttpException(400, "Bad request");
                }
                FriendList friendList = db.FriendLists.Where(fl => fl.personId == account.personId && fl.Person.Account.userName == userName).SingleOrDefault();
                if (friendList == null)
                {
                    throw new HttpException(404, "Not found");
                }
            }
            List <ViewModels.WishList> wishListItems = new List <ViewModels.WishList>();

            foreach (Wishlist wishList in db.Wishlists.Where(wl => wl.Person.Account.userName == userName))
            {
                ViewModels.WishList wishListItem = new ViewModels.WishList();
                wishListItem.wishlistId = wishList.wishlistId;
                wishListItem.gameId     = wishList.gameId;
                wishListItem.title      = wishList.Game.title;
                if (wishList.Game.GameDetails.Where(gd => gd.phyCopy).SingleOrDefault() != null)
                {
                    wishListItem.phyPrice = wishList.Game.GameDetails.Where(gd => gd.phyCopy).SingleOrDefault().price;
                }
                if (wishList.Game.GameDetails.Where(gd => !gd.phyCopy).SingleOrDefault() != null)
                {
                    wishListItem.downPrice = wishList.Game.GameDetails.Where(gd => !gd.phyCopy).SingleOrDefault().price;
                }
                wishListItems.Add(wishListItem);
            }
            return(View(wishListItems));
        }