From 018e9d303c38407589f06ec37a4a72dc4ce8e3b4 Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 13 Feb 2021 18:36:25 +0200 Subject: Merged New Project Structure; Fixed Kamen's Formatting Issues --- .../DevHive.Services/Interfaces/IPostService.cs | 2 +- .../DevHive.Services/Services/FeedService.cs | 4 ++-- .../DevHive.Services/Services/PostService.cs | 22 ++++++++--------- .../DevHive.Services/Services/UserService.cs | 28 +++++++++++----------- 4 files changed, 28 insertions(+), 28 deletions(-) (limited to 'src/Services') diff --git a/src/Services/DevHive.Services/Interfaces/IPostService.cs b/src/Services/DevHive.Services/Interfaces/IPostService.cs index d35acfd..5ccecff 100644 --- a/src/Services/DevHive.Services/Interfaces/IPostService.cs +++ b/src/Services/DevHive.Services/Interfaces/IPostService.cs @@ -4,7 +4,7 @@ using DevHive.Services.Models.Post; namespace DevHive.Services.Interfaces { - public interface IPostService + public interface IPostService { Task CreatePost(CreatePostServiceModel createPostServiceModel); diff --git a/src/Services/DevHive.Services/Services/FeedService.cs b/src/Services/DevHive.Services/Services/FeedService.cs index a0f1f1b..5feef6e 100644 --- a/src/Services/DevHive.Services/Services/FeedService.cs +++ b/src/Services/DevHive.Services/Services/FeedService.cs @@ -27,7 +27,7 @@ namespace DevHive.Services.Services /// /// This method is used in the feed page. /// See the FeedRepository "GetFriendsPosts" menthod for more information on how it works. - /// + /// public async Task GetPage(GetPageServiceModel model) { User user = null; @@ -58,7 +58,7 @@ namespace DevHive.Services.Services /// /// This method is used in the profile pages. /// See the FeedRepository "GetUsersPosts" menthod for more information on how it works. - /// + /// public async Task GetUserPage(GetPageServiceModel model) { User user = null; diff --git a/src/Services/DevHive.Services/Services/PostService.cs b/src/Services/DevHive.Services/Services/PostService.cs index c368ce6..0becd9f 100644 --- a/src/Services/DevHive.Services/Services/PostService.cs +++ b/src/Services/DevHive.Services/Services/PostService.cs @@ -13,7 +13,7 @@ using DevHive.Data.Models.Relational; namespace DevHive.Services.Services { - public class PostService : IPostService + public class PostService : IPostService { private readonly ICloudService _cloudService; private readonly IUserRepository _userRepository; @@ -144,8 +144,8 @@ namespace DevHive.Services.Services #region Validations /// - /// Checks whether the user Id in the token and the given user Id match - /// + /// Checks whether the user Id in the token and the given user Id match + /// public async Task ValidateJwtForCreating(Guid userId, string rawTokenData) { User user = await this.GetUserForValidation(rawTokenData); @@ -154,10 +154,10 @@ namespace DevHive.Services.Services } /// - /// Checks whether the post, gotten with the postId, + /// Checks whether the post, gotten with the postId, /// is made by the user in the token /// or if the user in the token is an admin - /// + /// public async Task ValidateJwtForPost(Guid postId, string rawTokenData) { Post post = await this._postRepository.GetByIdAsync(postId) ?? @@ -175,10 +175,10 @@ namespace DevHive.Services.Services } /// - /// Checks whether the comment, gotten with the commentId, + /// Checks whether the comment, gotten with the commentId, /// is made by the user in the token /// or if the user in the token is an admin - /// + /// public async Task ValidateJwtForComment(Guid commentId, string rawTokenData) { Comment comment = await this._commentRepository.GetByIdAsync(commentId) ?? @@ -196,8 +196,8 @@ namespace DevHive.Services.Services } /// - /// Returns the user, via their Id in the token - /// + /// Returns the user, via their Id in the token + /// private async Task GetUserForValidation(string rawTokenData) { JwtSecurityToken jwt = new JwtSecurityTokenHandler().ReadJwtToken(rawTokenData.Remove(0, 7)); @@ -212,8 +212,8 @@ namespace DevHive.Services.Services } /// - /// Returns all values from a given claim type - /// + /// Returns all values from a given claim type + /// private List GetClaimTypeValues(string type, IEnumerable claims) { List toReturn = new(); diff --git a/src/Services/DevHive.Services/Services/UserService.cs b/src/Services/DevHive.Services/Services/UserService.cs index f2c5a5b..9a63853 100644 --- a/src/Services/DevHive.Services/Services/UserService.cs +++ b/src/Services/DevHive.Services/Services/UserService.cs @@ -54,9 +54,9 @@ namespace DevHive.Services.Services #region Authentication /// - /// Adds a new user to the database with the values from the given model. + /// Adds a new user to the database with the values from the given model. /// Returns a JSON Web Token (that can be used for authorization) - /// + /// public async Task LoginUser(LoginServiceModel loginModel) { if (!await this._userRepository.DoesUsernameExistAsync(loginModel.UserName)) @@ -71,8 +71,8 @@ namespace DevHive.Services.Services } /// - /// Returns a new JSON Web Token (that can be used for authorization) for the given user - /// + /// Returns a new JSON Web Token (that can be used for authorization) for the given user + /// public async Task RegisterUser(RegisterServiceModel registerModel) { if (await this._userRepository.DoesUsernameExistAsync(registerModel.UserName)) @@ -143,8 +143,8 @@ namespace DevHive.Services.Services } /// - /// Uploads the given picture and assigns it's link to the user in the database - /// + /// Uploads the given picture and assigns it's link to the user in the database + /// public async Task UpdateProfilePicture(UpdateProfilePictureServiceModel updateProfilePictureServiceModel) { User user = await this._userRepository.GetByIdAsync(updateProfilePictureServiceModel.UserId); @@ -183,10 +183,10 @@ namespace DevHive.Services.Services #region Validations /// - /// Checks whether the given user, gotten by the "id" property, + /// Checks whether the given user, gotten by the "id" property, /// is the same user as the one in the token (uness the user in the token has the admin role) /// and the roles in the token are the same as those in the user, gotten by the id in the token - /// + /// public async Task ValidJWT(Guid id, string rawTokenData) { // There is authorization name in the beginning, i.e. "Bearer eyJh..." @@ -220,8 +220,8 @@ namespace DevHive.Services.Services } /// - /// Returns all values from a given claim type - /// + /// Returns all values from a given claim type + /// private List GetClaimTypeValues(string type, IEnumerable claims) { List toReturn = new(); @@ -234,10 +234,10 @@ namespace DevHive.Services.Services } /// - /// Checks whether the user in the model exists + /// Checks whether the user in the model exists /// and whether the username in the model is already taken. /// If the check fails (is false), it throws an exception, otherwise nothing happens - /// + /// private async Task ValidateUserOnUpdate(UpdateUserServiceModel updateUserServiceModel) { if (!await this._userRepository.DoesUserExistAsync(updateUserServiceModel.Id)) @@ -259,9 +259,9 @@ namespace DevHive.Services.Services } /// - /// Return a new JSON Web Token, containing the user id, username and roles. + /// Return a new JSON Web Token, containing the user id, username and roles. /// Tokens have an expiration time of 7 days. - /// + /// private string WriteJWTSecurityToken(Guid userId, string username, HashSet roles) { byte[] signingKey = Encoding.ASCII.GetBytes(_jwtOptions.Secret); -- cgit v1.2.3