示例#1
0
 public User UpdateUser(User user)
 {
     User result = _context.Users.FirstOrDefault(u => u.Id == user.Id);
     if (result != null)
     {
         result.Name = user.Name;
         result.GroupId = user.GroupId;
         _context.SaveChanges();
     }
     return result;
 }
示例#2
0
 public User CreateUser(string name)
 {
     User result = GetUserByUserNickName(name);
     if (result == null)
     {
         result = new User()
         {
             Name = name
         };
         _context.Users.Add(result);
         _context.SaveChanges();
     }
     return result;
 }