Exemplo n.º 1
0
 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");
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public int ChangeUserServiceArea(int areaId)
        {
            string areaName = "";

            if (User.Identity.IsAuthenticated)
            {
                UserModel userModel = new UserModel();
                UserInfo userInfo = userModel.GetUserInfo(User.Identity.Name);
                UserDefaultArea defaultArea;
                if (userInfo.UserDefaultArea.Count == 0)
                {
                    defaultArea = new UserDefaultArea();
                    defaultArea.UserId = userInfo.Id;
                    defaultArea.AreaId = areaId;
                    userModel.Add(defaultArea);
                }
                else
                {
                    defaultArea = userModel.GetUserDefaultArea(userInfo.Id);
                    defaultArea.AreaId = areaId;
                    userModel.Save();
                }
                areaName = defaultArea.ServiceArea.Value;
            }
            else
            {
                BaseDataModel baseModel = new BaseDataModel();
                areaName =  baseModel.GetServiceArea(areaId).Value;
            }

            System.Web.HttpCookie areaCookie = new System.Web.HttpCookie("udefaultarea");
            areaCookie.Domain = BaseDataModel.CookieDomain;
            areaCookie.Values["Id"] = areaId.ToString();
            areaCookie.Values["Name"] = HttpUtility.UrlEncode(areaName);
            areaCookie.Expires = DateTime.Now.AddYears(1);
            Response.Cookies.Set(areaCookie);
            return 1;
        }
Exemplo n.º 4
0
 public ActionResult GetServiceAreas(int id)
 {
     BaseDataModel baseDataModel = new BaseDataModel();
     var result = baseDataModel.GetServiceAreasWithCircels(id);
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 5
0
 public ActionResult GetLocations(int parentId)
 {
     BaseDataModel baseDataModel = new BaseDataModel();
     var result = baseDataModel.GetLocationsByParentId(parentId);
     return Json(result, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
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");
        }