/// <summary> /// 添加管理员 /// </summary> /// <param name="model"></param> /// <returns></returns> public static UserResult Add(AdminModel model) { UserResult result = new UserResult(); // 检查输入是否合法 if (!CheckName(model.Name)) { result.HasError = true; result.ErrorMessage = "用户名格式错误。"; result.Message = "name"; return(result); } if (AdminDAL.CheckEqualName(model.Name)) { result.HasError = true; result.ErrorMessage = "用户名重复"; result.Message = "name"; return(result); } if (!CheckPassword(model.Pass)) { result.HasError = true; result.ErrorMessage = "密码格式错误。"; result.Message = "password"; return(result); } //调用加密密码 model.Pass = Encrypt(model.Pass); // 调用数据层保存 int res = AdminDAL.Add(model); if (res > 0) { result.HasError = false; return(result); } else { result.HasError = true; result.ErrorMessage = "添加失败!"; return(result); } }
/// <summary> /// 获取管理员信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static UserResult GetAdminInfo(AdminModel model) { UserResult result = new UserResult(); // 检查输入是否合法 if (!CheckName(model.Name)) { result.HasError = true; result.ErrorMessage = "用户名格式错误。"; result.Message = "name"; return(result); } if (!AdminDAL.CheckEqualName(model.Name)) { result.HasError = true; result.ErrorMessage = "用户名错误"; result.Message = "name"; return(result); } if (!CheckPassword(model.Pass)) { result.HasError = true; result.ErrorMessage = "密码格式错误。"; result.Message = "password"; return(result); } //调用加密密码 model.Pass = Encrypt(model.Pass); result.Result = AdminDAL.GetAdminInfo(model); result.HasError = false; return(result); }
/// <summary> /// 管理员删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public static UserResult DeleteAdminByID(string id) { UserResult result = new UserResult(); if (!VerifyTool.IsLong(id)) { result.HasError = true; result.ErrorMessage = "参数错误。"; return(result); } if (AdminDAL.DeleteAdminByID(id)) { result.HasError = false; return(result); } else { result.HasError = true; result.ErrorMessage = "保留账号禁止删除!"; result.Message = "password"; return(result); } }