/// <summary> /// Creates a new user /// </summary> /// <param name="user">User to create</param> /// <returns>Created user, with filled id</returns> public async Task <GoNorthUser> CreateUser(GoNorthUser user) { user.Id = Guid.NewGuid().ToString(); await _UserCollection.InsertOneAsync(user); return(user); }
/// <summary> /// Gets a user by his normalized username /// </summary> /// <param name="normalizedUserName"></param> /// <returns>User</returns> public async Task <GoNorthUser> GetUserByNormalizedUserName(string normalizedUserName) { GoNorthUser user = await _UserCollection.Find(u => u.NormalizedUserName == normalizedUserName).FirstOrDefaultAsync(); return(user); }
/// <summary> /// Gets a user by his Id /// </summary> /// <param name="userId">User Id</param> /// <returns>User</returns> public async Task <GoNorthUser> GetUserById(string userId) { GoNorthUser user = await _UserCollection.Find(u => u.Id == userId).FirstOrDefaultAsync(); return(user); }
/// <summary> /// Deletes a user /// </summary> /// <param name="user">User</param> /// <returns>Task</returns> public async Task DeleteUser(GoNorthUser user) { DeleteResult result = await _UserCollection.DeleteOneAsync(u => u.Id == user.Id); }
/// <summary> /// Updates the security stamp for a user /// </summary> /// <param name="user">User</param> /// <param name="stamp">Security Stamp</param> /// <returns>Task</returns> public async Task UpdateSecurityStamp(GoNorthUser user, string stamp) { await _UserCollection.UpdateOneAsync(Builders <GoNorthUser> .Filter.Eq(u => u.Id, user.Id), Builders <GoNorthUser> .Update.Set(u => u.SecurityStamp, stamp)); }
/// <summary> /// Updates a user /// </summary> /// <param name="user">User</param> /// <returns>Task</returns> public async Task UpdateUser(GoNorthUser user) { ReplaceOneResult result = await _UserCollection.ReplaceOneAsync(u => u.Id == user.Id, user); }