Ejemplo n.º 1
0
        /// <summary>
        /// 增加
        /// </summary>
        /// <returns></returns>
        public ActionResult Update(WST.Model.Adviser entity)
        {
            ModelState.Remove("UpdatedTime");
            ModelState.Remove("CreatedTime");
            if (ModelState.IsValid)
            {
                var model = IAdviserService.Find(entity.ID);
                if (model == null || (model != null && model.IsDelete))
                {
                    return(DataErorrJResult());
                }

                if (IAdviserService.IsExits(x => x.Name == entity.Name && x.ID != entity.ID))
                {
                    return(JResult(Core.Code.ErrorCode.system_name_already_exist, ""));
                }

                model.Name   = entity.Name;
                model.Mobile = entity.Mobile;
                model.Sex    = entity.Sex;
                var result = IAdviserService.Update(model);
                return(JResult(result));
            }
            else
            {
                return(ParamsErrorJResult(ModelState));
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 增加
 /// </summary>
 /// <returns></returns>
 public ActionResult Add(WST.Model.Adviser entity)
 {
     ModelState.Remove("ID");
     ModelState.Remove("UpdatedTime");
     ModelState.Remove("CreatedTime");
     if (ModelState.IsValid)
     {
         if (IAdviserService.IsExits(x => x.Name == entity.Name))
         {
             return(JResult(Core.Code.ErrorCode.user_account_already_exist));
         }
         entity.CreatedTime = entity.UpdatedTime = DateTime.Now;
         var result = IAdviserService.Add(entity);
         return(JResult(result));
     }
     else
     {
         return(ParamsErrorJResult(ModelState));
     }
 }