public ActionResult AddAdvertisingSpace(AdvertisingSpaceInfoModel paraModel) { var model = new BaseReturnModel() { IsSuccess = false, ReturnMsg = "操作失败" }; try { _advertisingSpaceService.Insert(new AdvertisingSpaceInfo() { Height = paraModel.Height, Width = paraModel.Width, Sign = Guid.NewGuid().ToString("N"), Intro = paraModel.Intro, Title = paraModel.Title, TypeId = paraModel.TypeId, CreateOn = DateTime.Now }); model.IsSuccess = true; model.ReturnMsg = "添加完成"; } catch (Exception ex) { model.IsSuccess = false; model.ReturnMsg = ex.Message; } return(Json(model)); }
public void Update(AdvertisingSpaceInfoModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } using (var db = new BaseDatabaseContext()) { var oldEntity = db.AdvertisingSpaceInfos.FirstOrDefault(q => q.Id == model.Id); if (oldEntity == null) { throw new Exception("oldEntity is null"); } oldEntity = model.ToEntity(oldEntity); db.SaveChanges(); } }
public ActionResult EditAdvertisingSpace(AdvertisingSpaceInfoModel paraModel) { var model = new BaseReturnModel() { IsSuccess = false, ReturnMsg = "操作失败" }; try { _advertisingSpaceService.Update(paraModel); model.IsSuccess = true; model.ReturnMsg = "编辑完成"; } catch (Exception ex) { model.IsSuccess = false; model.ReturnMsg = ex.Message; } return(Json(model)); }
public static AdvertisingSpaceInfo ToEntity(this AdvertisingSpaceInfoModel model, AdvertisingSpaceInfo destination) { return(model.MapTo(destination)); }
public static AdvertisingSpaceInfo ToEntity(this AdvertisingSpaceInfoModel model) { return(model.MapTo <AdvertisingSpaceInfoModel, AdvertisingSpaceInfo>()); }