예제 #1
0
        public ActionResult Detail(int id, int p = 1)
        {
            id = 173;
            ShopModel shopModel = new ShopModel();
            V_ShopDetail shopInfo = shopModel.GetShopDetail(id);

            if (shopInfo == null)
                return RedirectToAction("HttpError404", "Error");

            /*ShopRankingAttribute rankAttr = shopModel.GetShopRankingAttribute(id);
            rankAttr.Visits += 1;
            shopModel.Save();*/

            ViewData["ShowShopPhone"] = true;

            var shopComments = shopModel.GetShopCommentsWithUserInfo(id);
            var shopServiceAreas = shopModel.GetShopServiceAreas(id);
            var shopDishes = shopModel.GetShopDishesWithCategory(id);

            ViewBag.UserFavoriteThisShop = false;
            ViewBag.UserId = -1;
            if(User.Identity.IsAuthenticated)
            {
                UserModel userModel = new UserModel();
                UserInfo userInfo = userModel.GetUserInfo(User.Identity.Name);
                ViewBag.UserId = userInfo.Id;
                ViewBag.UserName = userInfo.Name;
                UserFavoriteShop userFavoriteShop = userModel.GetUserFavoriteShop(id, userInfo.Id);
                if(userFavoriteShop != null)
                    ViewBag.UserFavoriteThisShop = true;
            }

            ViewBag.Id = id;
            Session["ShopDetailPhone"] = shopInfo.PhoneNumber;

            int pageSize = 5;
            int shopCommentsCount = shopComments.Count();
            ViewBag.ShopCommentsCount = shopCommentsCount;
            Paging.ToPaging(p, shopCommentsCount, this, pageSize);

            return View(new ShopDetailModel(shopInfo, shopServiceAreas, shopDishes, shopComments.Skip((p - 1) * pageSize).Take(pageSize)));
        }