public object GetInfoByUserName(dynamic parameters)
{
try
{
List<UserInfo> listInfo = new List<UserInfo>();
listInfo.Add(new UserInfo { UserID = 1, UserName = "张三1", Tel = "13333333333", Address = "beijing1" });
listInfo.Add(new UserInfo { UserID = 2, UserName = "张三2", Tel = "23333333333", Address = "beijing2" });
listInfo.Add(new UserInfo { UserID = 3, UserName = "张三3", Tel = "33333333333", Address = "beijing3" });
listInfo.Add(new UserInfo { UserID = 4, UserName = "张三4", Tel = "43333333333", Address = "beijing4" });
listInfo.Add(new UserInfo { UserID = 5, UserName = "张三5", Tel = "53333333333", Address = "beijing5" });
if (parameters == null)
{
return new ResultData<string>() { ResultFlag = 0, ResultCode = "0001", ResultMsg = "请求参数参数为空", ResultDatas = "" };
}
string temUserName=parameters.UserName;
UserInfo temInfo = listInfo.Where(x => x.UserName.Equals(temUserName.Trim())).FirstOrDefault();
return new ResultData<UserInfo>() { ResultFlag = 1, ResultCode = "0002", ResultMsg = "", ResultDatas = temInfo };
}
catch (Exception ex)
{
string errorMsg = string.Format("参考数据:{0},异常消息:{1},异常代码{2}",parameters,ex.Message,ex.StackTrace);
LogHelper.Error(errorMsg);
return new ResultData<string>() { ResultFlag = 0, ResultCode = "0003", ResultMsg = "操作失败", ResultDatas = "" };
}
}