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; }
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; }