refactor: MongoDB 消除警告信息
This commit is contained in:
parent
5728ee8983
commit
988e71402c
|
@ -75,7 +75,8 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
{
|
||||
var groups = GroupHelper.Retrieves();
|
||||
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.Id == userId);
|
||||
groups.ToList().ForEach(g => g.Checked = user.Groups.Any(id => id == g.Id) ? "checked" : "");
|
||||
if (user != null)
|
||||
groups.ToList().ForEach(g => g.Checked = user.Groups.Any(id => id == g.Id) ? "checked" : "");
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
@ -140,10 +141,10 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
public override IEnumerable<BootstrapGroup> RetrievesByUserName(string userName)
|
||||
{
|
||||
var groups = new List<BootstrapGroup>();
|
||||
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName == userName);
|
||||
var group = GroupHelper.Retrieves();
|
||||
|
||||
groups.AddRange(group.Where(g => user.Groups.Any(ug => ug == g.Id)));
|
||||
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName == userName);
|
||||
if (user != null)
|
||||
groups.AddRange(group.Where(g => user.Groups.Any(ug => ug == g.Id)));
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,8 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
{
|
||||
var roles = RoleHelper.Retrieves();
|
||||
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.Id == userId);
|
||||
roles.ToList().ForEach(r => r.Checked = user.Roles.Any(id => id == r.Id) ? "checked" : "");
|
||||
if (user != null)
|
||||
roles.ToList().ForEach(r => r.Checked = user.Roles.Any(id => id == r.Id) ? "checked" : "");
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
@ -188,7 +189,8 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
{
|
||||
var roles = RoleHelper.Retrieves();
|
||||
var group = GroupHelper.Retrieves().Cast<Group>().FirstOrDefault(u => u.Id == groupId);
|
||||
roles.ToList().ForEach(r => r.Checked = group.Roles.Any(id => id == r.Id) ? "checked" : "");
|
||||
if (group != null)
|
||||
roles.ToList().ForEach(r => r.Checked = group.Roles.Any(id => id == r.Id) ? "checked" : "");
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
|
|
@ -336,16 +336,19 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
public override bool Reject(string id, string rejectBy)
|
||||
{
|
||||
var user = UserHelper.RetrieveNewUsers().FirstOrDefault(u => u.Id == id);
|
||||
DbManager.RejectUsers.InsertOne(new RejectUser()
|
||||
if (user != null)
|
||||
{
|
||||
DisplayName = user.DisplayName,
|
||||
RegisterTime = user.RegisterTime,
|
||||
RejectedBy = rejectBy,
|
||||
RejectedReason = "",
|
||||
RejectedTime = DateTime.Now,
|
||||
UserName = user.UserName
|
||||
});
|
||||
DbManager.Users.DeleteOne(User => User.Id == id);
|
||||
DbManager.RejectUsers.InsertOne(new RejectUser()
|
||||
{
|
||||
DisplayName = user.DisplayName,
|
||||
RegisterTime = user.RegisterTime,
|
||||
RejectedBy = rejectBy,
|
||||
RejectedReason = "",
|
||||
RejectedTime = DateTime.Now,
|
||||
UserName = user.UserName
|
||||
});
|
||||
DbManager.Users.DeleteOne(User => User.Id == id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue