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() }));
            }
        }
Exemplo n.º 2
0
        /// <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));
        }
Exemplo n.º 3
0
 /// <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);
     }
 }
Exemplo n.º 4
0
 /// <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("保存失败"));
     }
 }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
 public static Craft ToEntity(this CraftModel model, Craft destination)
 {
     return(model.MapTo(destination));
 }
Exemplo n.º 7
0
 public static Craft ToEntity(this CraftModel model)
 {
     return(model.MapTo <CraftModel, Craft>());
 }
Exemplo n.º 8
0
 /// <summary>
 /// 更新一条数据.
 /// </summary>
 public void Update(CraftModel model)
 {
     DBProvider.dbMapper.Update("Craft_BaseInfo.Update", model);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 增加一条数据.
 /// </summary>
 public void Add(CraftModel model)
 {
     DBProvider.dbMapper.Insert("Craft_BaseInfo.Insert", model);
 }