/// <summary> /// 增加 /// </summary> /// <returns></returns> public ActionResult Update(GYM.Model.Admin entity) { ModelState.Remove("UpdaterID"); ModelState.Remove("UpdatedTime"); ModelState.Remove("CreatedTime"); ModelState.Remove("NewPassword"); ModelState.Remove("ConfirmPassword"); ModelState.Remove("Password"); ModelState.Remove("Type"); if (ModelState.IsValid) { var model = IAdminService.Find(entity.ID); if (model == null || (model != null && model.IsDelete)) { return(DataErorrJResult()); } if (IAdminService.IsExits(x => x.Account == entity.Account && x.ID != entity.ID)) { return(JResult(Core.Code.ErrorCode.store_city__namealready_exist, "")); } model.RealName = entity.RealName; model.Mobile = entity.Mobile; model.RoleID = entity.RoleID; model.Sex = entity.Sex; model.DepartmentID = entity.DepartmentID; var result = IAdminService.Update(model); return(JResult(result)); } else { return(ParamsErrorJResult(ModelState)); } }
/// <summary> /// 增加 /// </summary> /// <returns></returns> public ActionResult Add(GYM.Model.Admin entity) { ModelState.Remove("ID"); ModelState.Remove("UpdaterID"); ModelState.Remove("UpdatedTime"); ModelState.Remove("CreatedTime"); ModelState.Remove("Type"); if (ModelState.IsValid) { if (IAdminService.IsExits(x => x.Account == entity.Account)) { return(JResult(Core.Code.ErrorCode.user_account_already_exist)); } entity.Password = CryptoHelper.MD5_Encrypt(entity.ConfirmPassword); entity.Type = AdminCode.Admin; entity.CreatedTime = entity.UpdatedTime = DateTime.Now; var result = IAdminService.Add(entity); return(JResult(result)); } else { return(ParamsErrorJResult(ModelState)); } }