diff options
| author | transtrike <transtrike@gmail.com> | 2021-01-18 23:52:15 +0200 |
|---|---|---|
| committer | transtrike <transtrike@gmail.com> | 2021-01-18 23:52:15 +0200 |
| commit | b81cdf3b60914e821de6a3ad35dc2af6637bca0c (patch) | |
| tree | fe86eea7467f29572514059d2c5ab39522cee4dd /src/DevHive.Services | |
| parent | f0398cf1b7e6477bbd184e7509a1030054fc1926 (diff) | |
| download | DevHive-b81cdf3b60914e821de6a3ad35dc2af6637bca0c.tar DevHive-b81cdf3b60914e821de6a3ad35dc2af6637bca0c.tar.gz DevHive-b81cdf3b60914e821de6a3ad35dc2af6637bca0c.zip | |
Fixed default(x) to null
Diffstat (limited to 'src/DevHive.Services')
| -rw-r--r-- | src/DevHive.Services/Services/UserService.cs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs index b549b1c..d4c6f81 100644 --- a/src/DevHive.Services/Services/UserService.cs +++ b/src/DevHive.Services/Services/UserService.cs @@ -102,7 +102,7 @@ namespace DevHive.Services.Services User user = await this._userRepository.GetByIdAsync(userId); User friend = await this._userRepository.GetByIdAsync(friendId); - return user != default(User) && friend != default(User) ? + return user != null && friend != null ? await this._userRepository.AddFriendToUserAsync(user, friend) : throw new ArgumentException("Invalid user!"); } @@ -122,7 +122,7 @@ namespace DevHive.Services.Services { User friend = await this._userRepository.GetByUsernameAsync(username); - if (default(User) == friend) + if (friend == null) throw new ArgumentException("User does not exist!"); return this._userMapper.Map<UserServiceModel>(friend); @@ -142,13 +142,18 @@ namespace DevHive.Services.Services await this.ValidateUserCollections(updateUserServiceModel); - //Query proper lang, tech and role and insert the full class in updateUserServiceModel List<Language> properLanguages = new(); foreach (UpdateUserCollectionServiceModel lang in updateUserServiceModel.Languages) properLanguages.Add(await this._languageRepository.GetByNameAsync(lang.Name)); + List<Technology> properTechnologies = new(); + foreach (UpdateUserCollectionServiceModel tech in updateUserServiceModel.Technologies) + properTechnologies.Add(await this._technologyRepository.GetByNameAsync(tech.Name)); + User user = this._userMapper.Map<User>(updateUserServiceModel); + user.Languages = properLanguages; + user.Technologies = properTechnologies; bool success = await this._userRepository.EditAsync(user); @@ -165,7 +170,7 @@ namespace DevHive.Services.Services { User returnedFriend = await this._userRepository.GetByUsernameAsync(friend.Name); - if (default(User) == returnedFriend) + if (returnedFriend == null) throw new ArgumentException($"User {friend.Name} does not exist!"); } |
