public void InsertAdvContent() { var now = DateTime.Now; _advContentInfoService.Insert(new AdvContentInfo() { AdvertisingSpaceInfoSign = "e5ff2033c4724b0aa3829045f06c7161", Title = "测试广告内容三", CreateOn = DateTime.Now }); }
public ActionResult AddAdvContent(AdvContentInfoModel paraModel, FormCollection form) { var model = new BaseReturnModel() { IsSuccess = false, ReturnMsg = "操作失败" }; try { var entity = new AdvContentInfo() { AdvertisingSpaceInfoSign = paraModel.AdvertisingSpaceInfoSign, Title = paraModel.Title, Order = paraModel.Order, Intro = paraModel.Intro, TargetType = paraModel.TargetType, ContentJsonKeyword = paraModel.ContentJsonKeyword, Price = paraModel.Price, BeginDatetime = paraModel.BeginDatetime, EndDateTime = paraModel.EndDateTime, Type = paraModel.Type }; switch (paraModel.Type) { case AdvContentInfoType.Word: var wordModel = new AdvContentWordModel() { WordTitle = form["WordTitle"], WordSize = form["WordSize"], WordColor = form["WordColor"], WordLink = form["WordLink"] }; entity.ContentJson = JsonConvert.SerializeObject(wordModel); break; case AdvContentInfoType.Pic: var picModel = new AdvContentPicModel() { PicUrl = form["PicUrl"], PicImageAlt = form["PicImageAlt"], PicLink = form["PicLink"] }; entity.ContentJson = JsonConvert.SerializeObject(picModel); break; default: break; } _advContentInfoService.Insert(entity); model.IsSuccess = true; model.ReturnMsg = "添加完成"; } catch (Exception ex) { model.IsSuccess = false; model.ReturnMsg = ex.Message; } return(Json(model)); }