예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
 /// <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);
 }
예제 #5
0
 /// <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));
 }
예제 #6
0
 /// <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);
 }