重构代码:SaveUser方法使用ExecuteNonQuery返回值
This commit is contained in:
parent
8ea2ef2995
commit
9f9f09c47e
|
@ -104,6 +104,7 @@ namespace Bootstrap.DataAccess
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool SaveUser(User p)
|
public static bool SaveUser(User p)
|
||||||
{
|
{
|
||||||
|
var ret = false;
|
||||||
if (p.Id == 0 && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
|
if (p.Id == 0 && p.Description.Length > 500) p.Description = p.Description.Substring(0, 500);
|
||||||
if (p.UserName.Length > 50) p.UserName = p.UserName.Substring(0, 50);
|
if (p.UserName.Length > 50) p.UserName = p.UserName.Substring(0, 50);
|
||||||
p.PassSalt = LgbCryptography.GenerateSalt();
|
p.PassSalt = LgbCryptography.GenerateSalt();
|
||||||
|
@ -119,10 +120,10 @@ namespace Bootstrap.DataAccess
|
||||||
if (p.ApprovedTime == DateTime.MinValue) approvedTime = DBNull.Value;
|
if (p.ApprovedTime == DateTime.MinValue) approvedTime = DBNull.Value;
|
||||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedTime", approvedTime));
|
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@approvedTime", approvedTime));
|
||||||
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@description", p.Description));
|
cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@description", p.Description));
|
||||||
DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd);
|
ret = DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd) == -1;
|
||||||
}
|
}
|
||||||
CacheCleanUtility.ClearCache(userIds: p.Id == 0 ? string.Empty : p.Id.ToString());
|
CacheCleanUtility.ClearCache(userIds: p.Id == 0 ? string.Empty : p.Id.ToString());
|
||||||
return true;
|
return ret;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in New Issue