Remove unnecessary code from user services
This commit is contained in:
		| @@ -84,39 +84,6 @@ namespace Core.Thalos.Provider.Contracts | ||||
|         /// the asynchronous execution of the service.</returns> | ||||
|         ValueTask<UserAdapter?> LogOutUserSession(string email, CancellationToken cancellationToken); | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Adds a company to the user's list of companies. | ||||
|         /// </summary> | ||||
|         /// <param name="userId">The identifier of the user to whom the company will be added.</param> | ||||
|         /// <param name="companyId">The identifier of the company to add.</param> | ||||
|         /// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns> | ||||
|         ValueTask<UserAdapter> AddCompanyToUser(string userId, string companyId, CancellationToken cancellationToken); | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Removes a company from the user's list of companies. | ||||
|         /// </summary> | ||||
|         /// <param name="userId">The identifier of the user from whom the company will be removed.</param> | ||||
|         /// <param name="companyId">The identifier of the company to remove.</param> | ||||
|         /// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns> | ||||
|         ValueTask<UserAdapter> RemoveCompanyFromUser(string userId, string companyId, CancellationToken cancellationToken); | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Adds a project to the user's list of projects. | ||||
|         /// </summary> | ||||
|         /// <param name="userId">The identifier of the user to whom the project will be added.</param> | ||||
|         /// <param name="projectId">The identifier of the project to add.</param> | ||||
|         /// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns> | ||||
|         ValueTask<UserAdapter> AddProjectToUser(string userId, string projectId, CancellationToken cancellationToken); | ||||
|  | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Removes a project from the user's list of projects. | ||||
|         /// </summary> | ||||
|         /// <param name="userId">The identifier of the user from whom the project will be removed.</param> | ||||
|         /// <param name="projectId">The identifier of the project to remove.</param> | ||||
|         /// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns> | ||||
|         ValueTask<UserAdapter> RemoveProjectFromUser(string userId, string projectId, CancellationToken cancellationToken); | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets the token adapter for a user. | ||||
|         /// </summary> | ||||
|   | ||||
| @@ -209,92 +209,6 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|             return user; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Adds a company to the user's list of companies. | ||||
|         /// </summary> | ||||
|         /// <param name="userId">The identifier of the user to whom the company will be added.</param> | ||||
|         /// <param name="companyId">The identifier of the company to add.</param> | ||||
|         /// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns> | ||||
|         public async ValueTask<UserAdapter> AddCompanyToUser(string userId, string companyId, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var user = await repository.FindOneAsync( | ||||
|                 u => u._Id == userId && | ||||
|                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); | ||||
|  | ||||
|             var updatedCompanies = user.Companies.Append(companyId).Distinct().ToArray(); | ||||
|             user.Companies = updatedCompanies; | ||||
|  | ||||
|             await repository.ReplaceOneAsync(user); | ||||
|  | ||||
|             return user; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Removes a company from the user's list of companies. | ||||
|         /// </summary> | ||||
|         /// <param name="userId">The identifier of the user from whom the company will be removed.</param> | ||||
|         /// <param name="companyId">The identifier of the company to remove.</param> | ||||
|         /// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns> | ||||
|         public async ValueTask<UserAdapter> RemoveCompanyFromUser(string userId, string companyId, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var user = await repository.FindOneAsync( | ||||
|                 u => u._Id == userId && | ||||
|                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); | ||||
|  | ||||
|             var updatedCompanies = user.Companies | ||||
|                     ?.Where(c => c != companyId) | ||||
|                     .ToArray(); | ||||
|  | ||||
|             user.Companies = updatedCompanies; | ||||
|  | ||||
|             await repository.ReplaceOneAsync(user); | ||||
|  | ||||
|             return user; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Adds a project to the user's list of projects. | ||||
|         /// </summary> | ||||
|         /// <param name="userId">The identifier of the user to whom the project will be added.</param> | ||||
|         /// <param name="projectId">The identifier of the project to add.</param> | ||||
|         /// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns> | ||||
|         public async ValueTask<UserAdapter> AddProjectToUser(string userId, string projectId, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var user = await repository.FindOneAsync( | ||||
|                 u => u._Id == userId && | ||||
|                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); | ||||
|  | ||||
|             var updatedProjects = user.Projects.Append(projectId).Distinct().ToArray(); | ||||
|             user.Projects = updatedProjects; | ||||
|  | ||||
|             await repository.ReplaceOneAsync(user); | ||||
|  | ||||
|             return user; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Removes a project from the user's list of projects. | ||||
|         /// </summary> | ||||
|         /// <param name="userId">The identifier of the user from whom the project will be removed.</param> | ||||
|         /// <param name="projectId">The identifier of the project to remove.</param> | ||||
|         /// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns> | ||||
|         public async ValueTask<UserAdapter> RemoveProjectFromUser(string userId, string projectId, CancellationToken cancellationToken) | ||||
|         { | ||||
|             var user = await repository.FindOneAsync( | ||||
|                 u => u._Id == userId && | ||||
|                 u.Status == Core.Blueprint.Mongo.StatusEnum.Active); | ||||
|  | ||||
|             var updatedProjects = user.Projects | ||||
|                     ?.Where(c => c != projectId) | ||||
|                     .ToArray(); | ||||
|  | ||||
|             user.Projects = updatedProjects; | ||||
|  | ||||
|             await repository.ReplaceOneAsync(user); | ||||
|  | ||||
|             return user; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Gets the token adapter for a user. | ||||
|         /// </summary> | ||||
| @@ -411,18 +325,6 @@ namespace Core.Thalos.Provider.Providers.Onboarding | ||||
|                         LastName = result.Contains("lastName") && !result["lastName"].IsBsonNull ? result["lastName"].AsString : "", | ||||
|                         DisplayName = result.Contains("displayName") && !result["displayName"].IsBsonNull ? result["displayName"].AsString : "", | ||||
|                         RoleId = result.Contains("roleId") && !result["roleId"].IsBsonNull ? result["roleId"].ToString() : "", | ||||
|                         Companies = result.Contains("companies") && result["companies"].IsBsonArray | ||||
|                             ? result["companies"].AsBsonArray | ||||
|                                 .Where(c => c != null && !c.IsBsonNull) | ||||
|                                 .Select(c => c.AsString) | ||||
|                                 .ToArray() | ||||
|                             : Array.Empty<string>(), | ||||
|                         Projects = result.Contains("projects") && result["projects"].IsBsonArray | ||||
|                             ? result["projects"].AsBsonArray | ||||
|                                 .Where(p => p != null && !p.IsBsonNull) | ||||
|                                 .Select(p => p.AsString) | ||||
|                                 .ToArray() | ||||
|                             : Array.Empty<string>(), | ||||
|                         LastLogIn = result.Contains("lastLogIn") && !result["lastLogIn"].IsBsonNull ? result["lastLogIn"].ToUniversalTime() : DateTime.MinValue, | ||||
|                         LastLogOut = result.Contains("lastLogOut") && !result["lastLogOut"].IsBsonNull ? result["lastLogOut"].ToUniversalTime() : DateTime.MinValue, | ||||
|                         CreatedAt = result.Contains("createdAt") && !result["createdAt"].IsBsonNull ? result["createdAt"].ToUniversalTime() : DateTime.MinValue, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user