public ActionResult Edit(CraftModel model) { var craft = _craftRepository.GetById(model.Id); if (ModelState.IsValid) { craft = model.ToEntity(craft); //always set IsNew to false when saving craft.IsNew = false; //update attributes _craftRepository.Update(craft); //commit all changes this._dbContext.SaveChanges(); //notification SuccessNotification(_localizationService.GetResource("Record.Saved")); return(new NullJsonResult()); } else { return(Json(new { Errors = ModelState.SerializeErrors() })); } }
/// <summary> /// 获取一条数据 /// </summary> /// <param name="craftId"></param> /// <returns></returns> public ActionResult GetCraftById(string craftId) { CraftModel model = ServiceProvider.CraftService.GetById(UtilsHelper.Decrypt2Int(craftId)); if (model == null) { model = new CraftModel(); } return(Json(new { model = model }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 保存实体数据. /// </summary> public void Save(CraftModel model) { if (model.CraftId == 0) { model.CreateUser = LoginHelper.LoginUser.UserName; DBProvider.CraftDAO.Add(model); } else { DBProvider.CraftDAO.Update(model); } }
/// <summary> /// 保存 /// </summary> /// <param name="model"></param> /// <param name="collection"></param> /// <returns></returns> public ActionResult Save(CraftModel model, FormCollection collection) { try { ServiceProvider.CraftService.Save(model); return(Content("OK")); } catch (Exception ex) { log.Error(ex.ToString()); return(Content("保存失败")); } }
public ActionResult Edit(int craftId) { //部门...........生成一个下拉框树所需的数据源 ViewBag.OrgList = Global.Business.ServiceProvider.OrgService.GetAll(); CraftModel mCraft = ServiceProvider.CraftService.GetById(craftId); if (mCraft == null) { mCraft = new CraftModel(); } //return View(mCraft); return(View(mCraft)); }
public static Craft ToEntity(this CraftModel model, Craft destination) { return(model.MapTo(destination)); }
public static Craft ToEntity(this CraftModel model) { return(model.MapTo <CraftModel, Craft>()); }
/// <summary> /// 更新一条数据. /// </summary> public void Update(CraftModel model) { DBProvider.dbMapper.Update("Craft_BaseInfo.Update", model); }
/// <summary> /// 增加一条数据. /// </summary> public void Add(CraftModel model) { DBProvider.dbMapper.Insert("Craft_BaseInfo.Insert", model); }