public ActionResult Create() { BaseDataModel baseDataModel = new BaseDataModel(); var cityDistricts = baseDataModel.GetLocationsByParentId(214); ViewBag.CityDistrictSelectList = (new SelectList(cityDistricts, "Id", "Value")).ToList(); ViewBag.ShopsSelectList = new List<SelectListItem>(); return View("edit"); }
public ActionResult Edit(int id) { JobModel jobModel = new JobModel(); BaseDataModel baseDataModel = new BaseDataModel(); ShopJobAd jobAd = jobModel.GetShopJobAd(id); var cityDistricts = baseDataModel.GetLocationsByParentId(214); ViewBag.CityDistrictSelectList = (new SelectList(cityDistricts, "Id", "Value")).ToList(); List<SelectListItem> shopList = new List<SelectListItem>(); shopList.Add(new SelectListItem { Value = jobAd.ShopId.ToString(), Text = jobAd.Shop.Name, Selected = true }); ViewBag.ShopsSelectList = shopList; return View(jobAd); }
public ActionResult GetLocations(int parentId) { BaseDataModel baseDataModel = new BaseDataModel(); var result = baseDataModel.GetLocationsByParentId(parentId); return Json(result, JsonRequestBehavior.AllowGet); }
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)); }
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"); }