public ActionResult SaveAdertising(AdvertingInputModel model) { var bll = new AdvertisingBll(); Bas_Advertising dbModel = null; if (model.Bad_Id > 0) { dbModel = bll.GetAdvertisingById(model.Bad_Id); var modelByPos = bll.GetAdvertisingByPosId(model.Bad_PosId); if (dbModel == null || modelByPos == null || modelByPos.Bad_Id != dbModel.Bad_Id) { throw new AbhsException(ErrorCodeEnum.ParameterInvalid, AbhsErrorMsg.ConstParameterInvalid); } } //dbModel = model.ToAdvertisingDbModel(); //dbModel.Bad_Creator = CurrentUserID; dbModel = model.ConvertTo <Bas_Advertising>(dbModel); bool success = bll.SaveAdertising(dbModel); var msg = success ? "保存成功" : "保存失败"; return(Json(new JsonSimpleResponse() { State = success, ErrorMsg = msg })); }
public ActionResult Edit(int badPosId, int badId) { AdvertingInputModel viewModel; Bas_Advertising dbModel = null; if (badId > 0) { dbModel = new AdvertisingBll().GetAdvertisingById(badId); } if (dbModel == null) { viewModel = new AdvertingInputModel(badPosId); viewModel.Bad_Url = ""; } else { viewModel = new AdvertingInputModel(dbModel); } var bapModel = new AdvertisingBll().GetAdvertisingPosById(badPosId); if (bapModel != null) { viewModel.Bap_Code = bapModel.Bap_Code; } return(View(viewModel)); }