예제 #1
0
        public ActionResult Edit(int id)
        {
            ShopModel shopModel = new ShopModel();
            Shop shopBaseInfo = shopModel.GetShop(id);
            UserModel userModel = new UserModel();
            UserInfo userInfo = userModel.GetUserInfo(User.Identity.Name);
            if(userInfo.UserGradeCategory.GradeLevel != 9 && shopBaseInfo.CreateBy != userInfo.Id)
                return Redirect("/");
            List<V_ShopDisheWithCategory> shopDisheWithCategory = shopModel.GetShopDishesWithCategory(id).OrderByDescending(r => r.DisheCategoryOrder).ToList();

            var shopCategories = shopModel.GetShopCategories();

            SelectList shopCategoryList = new SelectList(shopCategories, "Id", "Value");
            List<SelectListItem> shopCategorySelectList = shopCategoryList.ToList();

            for(int i = 0; i < shopCategorySelectList.Count; i++)
                if(shopCategorySelectList[i].Value == shopBaseInfo.CategoryId.ToString())
                {
                    shopCategorySelectList[i].Selected = true;
                    break;
                }
            ViewBag.ShopCategorySelectList = shopCategorySelectList;

            BaseDataModel baseDataModel = new BaseDataModel();
            var cityDistricts = baseDataModel.GetLocationsByParentId(214);
            ViewBag.CityDistrictSelectList = (new SelectList(cityDistricts, "Id", "Value")).ToList();

            List<ServiceArea> shopServiceAraes = shopModel.GetShopServiceAreas(id).ToList()
                .Select(r => new ServiceArea() { Id = r.AreaId, ParentId = r.ParentId, Value = r.ServiceArea, AreaType = r.AreaType }).ToList();
            ViewBag.ServiceAreaSelectList = shopServiceAraes;

            ViewBag.ShopDisheCategoryList = shopDisheWithCategory.GroupBy(r => new { r.CategoryId, r.CategoryValue })
                .Select(r => new SelectListItem() { Value = r.Key.CategoryId.ToString(), Text = r.Key.CategoryValue }).ToList();

            ViewBag.ShopLogo = Url.Content(shopImagePath + shopBaseInfo.Logo);
            ViewBag.OffsetTime = offsetTime;
            return View(new ShopDetailEditorModel(shopBaseInfo, shopDisheWithCategory));
        }
예제 #2
0
        public ActionResult Create(int i = 1)
        {
            ShopModel shopModel = new ShopModel();
            var shopCategories = shopModel.GetShopCategories();

            SelectList shopCategoryList = new SelectList(shopCategories, "Id", "Value");
            List<SelectListItem> shopCategorySelectList = shopCategoryList.ToList();
            ViewBag.ShopCategorySelectList = shopCategorySelectList;

            BaseDataModel baseDataModel = new BaseDataModel();
            var cityDistricts = baseDataModel.GetLocationsByParentId(214);
            ViewBag.CityDistrictSelectList = (new SelectList(cityDistricts, "Id", "Value")).ToList();

            ViewBag.ServiceAreaSelectList = new List<ServiceArea>();
            ViewBag.ShopDisheCategoryList = new List<SelectListItem>();

            ViewBag.ShopLogo = Url.Content("/Contents/ShopImages/shop_default_icon.png");
            ViewBag.OffsetTime = offsetTime;

            return View("Edit");
        }