public ActionResult Save(PoiEditModel model) { string wxPath = ""; if (!string.IsNullOrEmpty(model.photo_list) && !(model.photo_list.IndexOf("http") >= 0)) { string path = Server.MapPath("~" + model.photo_list); wxPath = this._iPoiService.UploadImage(path); } if (model.id == 0) { StoreBaseInfo data = new StoreBaseInfo(); data.sid = Guid.NewGuid().ToString(); var province = Himall.Application.RegionApplication.GetRegion(model.RegionId, CommonModel.Region.RegionLevel.Province); var city = Himall.Application.RegionApplication.GetRegion(model.RegionId, CommonModel.Region.RegionLevel.City); var county = Himall.Application.RegionApplication.GetRegion(model.RegionId, CommonModel.Region.RegionLevel.County); data.province = province.Name; data.city = city.Name; data.district = county.Name; data.address = model.address; data.business_name = model.business_name; data.branch_name = model.branch_name; if (string.IsNullOrEmpty(model.categoryTwo)) { data.categories = new string[] { model.categoryOne }; } else { data.categories = new string[] { model.categoryOne + "," + model.categoryTwo }; } data.photo_list = new List <Store_Photo> { new Store_Photo { photo_url = wxPath } }; data.telephone = model.telephone; data.avg_price = model.avg_price; data.open_time = model.open_time; data.offset_type = 1; data.recommend = model.recommend; data.special = model.special; data.longitude = "0"; data.latitude = "0"; data.introduction = model.introduction; CreateStoreData cd = new CreateStoreData(); cd.business = new CreateStore_Business(); cd.business.base_info = data; bool result = this._iPoiService.AddPoi(cd); return(Json(new { success = result })); } else { UpdateStore_BaseInfo data = new UpdateStore_BaseInfo(); data.poi_id = model.poi_id; data.telephone = model.telephone; data.recommend = model.recommend; data.special = model.special; data.introduction = model.introduction; data.open_time = model.open_time; data.avg_price = model.avg_price; data.photo_list = new List <Store_Photo> { new Store_Photo { photo_url = wxPath } }; UpdateStoreData ud = new UpdateStoreData(); ud.business = new UpdateStore_Business(); ud.business.base_info = data; bool result = this._iPoiService.UpdatePoi(ud); return(Json(new { success = result })); } }
public ActionResult Save(PoiEditModel model) { string str = ""; if (!string.IsNullOrEmpty(model.photo_list) && model.photo_list.IndexOf("http") < 0) { string str1 = Server.MapPath(string.Concat("~", model.photo_list)); str = _poiService.UploadImage(str1); } if (model.id != 0) { UpdateStore_BaseInfo updateStoreBaseInfo = new UpdateStore_BaseInfo() { poi_id = model.poi_id, telephone = model.telephone, recommend = model.recommend, special = model.special, introduction = model.introduction, open_time = model.open_time, avg_price = model.avg_price }; List <Store_Photo> storePhotos = new List <Store_Photo>() { new Store_Photo() { photo_url = str } }; updateStoreBaseInfo.photo_list = storePhotos; UpdateStoreData updateStoreDatum = new UpdateStoreData() { business = new UpdateStore_Business() { base_info = updateStoreBaseInfo } }; bool flag = _poiService.UpdatePoi(updateStoreDatum); return(Json(new { success = flag })); } StoreBaseInfo storeBaseInfo = new StoreBaseInfo() { sid = Guid.NewGuid().ToString(), province = model.province, city = model.city, district = model.district, address = model.address, business_name = model.business_name, branch_name = model.branch_name }; string[] strArrays = new string[] { string.Concat(model.categoryOne, ",", model.categoryTwo) }; storeBaseInfo.categories = strArrays; List <Store_Photo> storePhotos1 = new List <Store_Photo>() { new Store_Photo() { photo_url = str } }; storeBaseInfo.photo_list = storePhotos1; storeBaseInfo.telephone = model.telephone; storeBaseInfo.avg_price = model.avg_price; storeBaseInfo.open_time = model.open_time; storeBaseInfo.offset_type = 1; storeBaseInfo.recommend = model.recommend; storeBaseInfo.special = model.special; storeBaseInfo.longitude = "0"; storeBaseInfo.latitude = "0"; storeBaseInfo.introduction = model.introduction; CreateStoreData createStoreDatum = new CreateStoreData() { business = new CreateStore_Business() { base_info = storeBaseInfo } }; bool flag1 = _poiService.AddPoi(createStoreDatum); return(Json(new { success = flag1 })); }