/// <summary> /// 验证数据 /// </summary> /// <param name="model">数据模型</param> /// <returns>验证成功返回空字符串;验证失败返回失败原因描述</returns> public string Validation(UserModel model, DbOperType ot) { StringBuilder errorMsg = new StringBuilder(); if (ot == DbOperType.Update) { if (string.IsNullOrWhiteSpace(model.user_id)) { errorMsg.Append("账号id不能为空,"); } } if (string.IsNullOrWhiteSpace(model.user_account)) { errorMsg.Append("用户账号不能为空,"); } string tmp = errorMsg.ToString(); return(tmp.Length > 0 ? tmp.Substring(0, tmp.Length - 1) : tmp); }
/// <summary> /// 验证数据 /// </summary> /// <param name="model">数据模型</param> /// <returns>验证成功返回空字符串;验证失败返回失败原因描述</returns> public string Validation(SystemModel model, DbOperType ot) { StringBuilder errorMsg = new StringBuilder(); if (ot == DbOperType.Update) { if (string.IsNullOrWhiteSpace(model.system_id)) { errorMsg.Append("系统编号不能为空,"); } } if (string.IsNullOrWhiteSpace(model.system_name)) { errorMsg.Append("系统名称不能为空,"); } string tmp = errorMsg.ToString(); return(tmp.Length > 0 ? tmp.Substring(0, tmp.Length - 1) : tmp); }