aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Services
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-01-21 19:21:46 +0200
committertranstrike <transtrike@gmail.com>2021-01-21 19:21:46 +0200
commitf8f3727319a03eb9dd9a2ed8546810beb732cdab (patch)
tree12bdc4b9262e3d8611a792525bdf793594a078f2 /src/DevHive.Services
parent9e86699c9b3aff17e0c4d19850b41b792a9625ef (diff)
downloadDevHive-f8f3727319a03eb9dd9a2ed8546810beb732cdab.tar
DevHive-f8f3727319a03eb9dd9a2ed8546810beb732cdab.tar.gz
DevHive-f8f3727319a03eb9dd9a2ed8546810beb732cdab.zip
Cleaning of UserRepo&UserService of unused methods
Diffstat (limited to 'src/DevHive.Services')
-rw-r--r--src/DevHive.Services/Interfaces/IUserService.cs5
-rw-r--r--src/DevHive.Services/Services/UserService.cs51
2 files changed, 0 insertions, 56 deletions
diff --git a/src/DevHive.Services/Interfaces/IUserService.cs b/src/DevHive.Services/Interfaces/IUserService.cs
index 923e9bb..51e3cf9 100644
--- a/src/DevHive.Services/Interfaces/IUserService.cs
+++ b/src/DevHive.Services/Interfaces/IUserService.cs
@@ -1,8 +1,6 @@
using System;
-using System.Collections.Generic;
using System.Threading.Tasks;
using DevHive.Common.Models.Identity;
-using DevHive.Common.Models.Misc;
using DevHive.Services.Models.Identity.User;
namespace DevHive.Services.Interfaces
@@ -12,15 +10,12 @@ namespace DevHive.Services.Interfaces
Task<TokenModel> LoginUser(LoginServiceModel loginModel);
Task<TokenModel> RegisterUser(RegisterServiceModel registerModel);
- Task<bool> AddFriend(Guid userId, Guid friendId);
-
Task<UserServiceModel> GetUserByUsername(string username);
Task<UserServiceModel> GetUserById(Guid id);
Task<UserServiceModel> UpdateUser(UpdateUserServiceModel updateModel);
Task DeleteUser(Guid id);
- Task<bool> RemoveFriend(Guid userId, Guid friendId);
Task<bool> ValidJWT(Guid id, string rawTokenData);
}
diff --git a/src/DevHive.Services/Services/UserService.cs b/src/DevHive.Services/Services/UserService.cs
index a57fd23..217154e 100644
--- a/src/DevHive.Services/Services/UserService.cs
+++ b/src/DevHive.Services/Services/UserService.cs
@@ -84,35 +84,7 @@ namespace DevHive.Services.Services
}
#endregion
- #region Create
-
- public async Task<bool> AddFriend(Guid userId, Guid friendId)
- {
- Task<bool> userExists = this._userRepository.DoesUserExistAsync(userId);
- Task<bool> friendExists = this._userRepository.DoesUserExistAsync(friendId);
-
- await Task.WhenAll(userExists, friendExists);
-
- if (!userExists.Result)
- throw new ArgumentException("User doesn't exist!");
-
- if (!friendExists.Result)
- throw new ArgumentException("Friend doesn't exist!");
-
- if (await this._userRepository.DoesUserHaveThisFriendAsync(userId, friendId))
- throw new ArgumentException("Friend already exists in your friends list.");
-
- User user = await this._userRepository.GetByIdAsync(userId);
- User friend = await this._userRepository.GetByIdAsync(friendId);
-
- return user != null && friend != null ?
- await this._userRepository.AddFriendToUserAsync(user, friend) :
- throw new ArgumentException("Invalid user!");
- }
- #endregion
-
#region Read
-
public async Task<UserServiceModel> GetUserById(Guid id)
{
User user = await this._userRepository.GetByIdAsync(id)
@@ -133,7 +105,6 @@ namespace DevHive.Services.Services
#endregion
#region Update
-
public async Task<UserServiceModel> UpdateUser(UpdateUserServiceModel updateUserServiceModel)
{
await this.ValidateUserOnUpdate(updateUserServiceModel);
@@ -191,7 +162,6 @@ namespace DevHive.Services.Services
#endregion
#region Delete
-
public async Task DeleteUser(Guid id)
{
if (!await this._userRepository.DoesUserExistAsync(id))
@@ -203,30 +173,9 @@ namespace DevHive.Services.Services
if (!result)
throw new InvalidOperationException("Unable to delete user!");
}
-
- public async Task<bool> RemoveFriend(Guid userId, Guid friendId)
- {
- bool userExists = await this._userRepository.DoesUserExistAsync(userId);
- bool friendExists = await this._userRepository.DoesUserExistAsync(friendId);
-
- if (!userExists)
- throw new ArgumentException("User doesn't exist!");
-
- if (!friendExists)
- throw new ArgumentException("Friend doesn't exist!");
-
- if (!await this._userRepository.DoesUserHaveThisFriendAsync(userId, friendId))
- throw new ArgumentException("This ain't your friend, amigo.");
-
- User user = await this._userRepository.GetByIdAsync(userId);
- User homie = await this._userRepository.GetByIdAsync(friendId);
-
- return await this._userRepository.RemoveFriendAsync(user, homie);
- }
#endregion
#region Validations
-
public async Task<bool> ValidJWT(Guid id, string rawTokenData)
{
// There is authorization name in the beginning, i.e. "Bearer eyJh..."