Ejemplo n.º 1
0
        public ActionResult AddPlace(int?placeId, int cityId = 136)
        {
            PlaceAddSubmitModel model = new PlaceAddSubmitModel();

            model.CityList = GetCityList();
            if (placeId == null)
            {
                ICityBLL cityBll = BLLFactory <ICityBLL> .GetBLL("CityBLL");

                var city = cityBll.GetEntity(c => c.Id == cityId);
                if (city == null)
                {
                    city = cityBll.GetEntity(c => c.Id == 136);
                }
                model.CityId    = city.Id;
                model.CityName  = city.CityName;
                model.PlaceList = GetPlaceList(city.Id);
            }
            else
            {
                IPropertyPlaceBLL placeBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

                var place = placeBll.GetEntity(c => c.Id == placeId.Value);
                model.CityId    = place.CityId;
                model.CityName  = place.City.CityName;
                model.PlaceId   = placeId.Value;
                model.PlaceList = GetPlaceList(place.CityId);
                model.PlaceName = place.Name;
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public JsonResult AddPlace(PlaceAddSubmitModel model)
        {
            JsonModel jm = new JsonModel();

            var owner = GetCurrentUser();
            //如果要添加的小区不存在
            IPropertyPlaceBLL propertyPlaceBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

            var place = propertyPlaceBll.GetEntity(u => u.Id == model.PlaceId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (place == null)
            {
                jm.Msg = "小区已不存在";
            }
            //如果该用户已经有要添加的小区
            else if (owner.UserPlaces.Any(up => up.UserId == owner.Id && up.PropertyPlaceId == model.PlaceId))
            {
                jm.Msg = "小区已绑定,请重新选择";
            }
            else
            {
                //添加拥有的小区
                owner.UserPlaces.Add(new R_UserPlace()
                {
                    PropertyPlaceId = model.PlaceId
                });

                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                ownerBll.Update(owner);
                jm.Content = model.PlaceId.ToString();
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }