aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-02-13 18:36:25 +0200
committertranstrike <transtrike@gmail.com>2021-02-13 18:36:25 +0200
commit018e9d303c38407589f06ec37a4a72dc4ce8e3b4 (patch)
tree05387c66338796a4c207c3bcbeca454329a28120 /src
parentd9b9685204ece098df5a2425246a10bf65004b0f (diff)
downloadDevHive-018e9d303c38407589f06ec37a4a72dc4ce8e3b4.tar
DevHive-018e9d303c38407589f06ec37a4a72dc4ce8e3b4.tar.gz
DevHive-018e9d303c38407589f06ec37a4a72dc4ce8e3b4.zip
Merged New Project Structure; Fixed Kamen's Formatting Issues
Diffstat (limited to 'src')
-rw-r--r--src/Data/DevHive.Data.Models/ProfilePicture.cs2
-rw-r--r--src/Data/DevHive.Data/Repositories/CommentRepository.cs5
-rw-r--r--src/Data/DevHive.Data/Repositories/FeedRepository.cs8
-rw-r--r--src/Data/DevHive.Data/Repositories/LanguageRepository.cs4
-rw-r--r--src/Data/DevHive.Data/Repositories/PostRepository.cs10
-rw-r--r--src/Data/DevHive.Data/Repositories/TechnologyRepository.cs4
-rw-r--r--src/DevHive.code-workspace1
-rw-r--r--src/Services/DevHive.Services/Interfaces/IPostService.cs2
-rw-r--r--src/Services/DevHive.Services/Services/FeedService.cs4
-rw-r--r--src/Services/DevHive.Services/Services/PostService.cs22
-rw-r--r--src/Services/DevHive.Services/Services/UserService.cs28
-rw-r--r--src/Web/DevHive.Web.Tests/PostController.Tests.cs2
-rw-r--r--src/Web/DevHive.Web.Tests/RoleController.Tests.cs2
-rw-r--r--src/Web/DevHive.Web.Tests/UserController.Tests.cs2
14 files changed, 47 insertions, 49 deletions
diff --git a/src/Data/DevHive.Data.Models/ProfilePicture.cs b/src/Data/DevHive.Data.Models/ProfilePicture.cs
index c5dec68..c502654 100644
--- a/src/Data/DevHive.Data.Models/ProfilePicture.cs
+++ b/src/Data/DevHive.Data.Models/ProfilePicture.cs
@@ -3,7 +3,7 @@ using DevHive.Data.Models.Interfaces;
namespace DevHive.Data.Models
{
- public class ProfilePicture: IProfilePicture
+ public class ProfilePicture : IProfilePicture
{
public Guid Id { get; set; }
diff --git a/src/Data/DevHive.Data/Repositories/CommentRepository.cs b/src/Data/DevHive.Data/Repositories/CommentRepository.cs
index c63fe65..9364776 100644
--- a/src/Data/DevHive.Data/Repositories/CommentRepository.cs
+++ b/src/Data/DevHive.Data/Repositories/CommentRepository.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using DevHive.Data.Interfaces;
@@ -29,8 +28,8 @@ namespace DevHive.Data.Repositories
}
/// <summary>
- /// This method returns the comment that is made at exactly the given time and by the given creator
- /// </summary>
+ /// This method returns the comment that is made at exactly the given time and by the given creator
+ /// </summary>
public async Task<Comment> GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated)
{
return await this._context.Comments
diff --git a/src/Data/DevHive.Data/Repositories/FeedRepository.cs b/src/Data/DevHive.Data/Repositories/FeedRepository.cs
index 8899675..d3312d7 100644
--- a/src/Data/DevHive.Data/Repositories/FeedRepository.cs
+++ b/src/Data/DevHive.Data/Repositories/FeedRepository.cs
@@ -19,14 +19,14 @@ namespace DevHive.Data.Repositories
}
/// <summary>
- /// This returns a given amount of posts of all given friends, created before "firstRequestIssued",
+ /// This returns a given amount of posts of all given friends, created before "firstRequestIssued",
/// ordered from latest to oldest (time created).
/// PageSize specifies how many posts to get, and pageNumber specifices how many posts to skip (pageNumber * pageSize).
///
/// This method is used in the feed page.
/// Posts from friends are meant to be gotten in chunks, meaning you get X posts, and then get another amount of posts,
/// that are after the first X posts.
- /// </summary>
+ /// </summary>
public async Task<List<Post>> GetFriendsPosts(List<User> friendsList, DateTime firstRequestIssued, int pageNumber, int pageSize)
{
List<Guid> friendsIds = friendsList.Select(f => f.Id).ToList();
@@ -49,14 +49,14 @@ namespace DevHive.Data.Repositories
}
/// <summary>
- /// This returns a given amount of posts, that a user has made, created before "firstRequestIssued",
+ /// This returns a given amount of posts, that a user has made, created before "firstRequestIssued",
/// ordered from latest to oldest (time created).
/// PageSize specifies how many posts to get, and pageNumber specifices how many posts to skip (pageNumber * pageSize).
///
/// This method is used in the profile page.
/// Posts from friends are meant to be gotten in chunks, meaning you get X posts, and then get another amount of posts,
/// that are after the first X posts.
- /// </summary>
+ /// </summary>
public async Task<List<Post>> GetUsersPosts(User user, DateTime firstRequestIssued, int pageNumber, int pageSize)
{
List<Post> posts = await this._context.Posts
diff --git a/src/Data/DevHive.Data/Repositories/LanguageRepository.cs b/src/Data/DevHive.Data/Repositories/LanguageRepository.cs
index 61f4792..3528ea8 100644
--- a/src/Data/DevHive.Data/Repositories/LanguageRepository.cs
+++ b/src/Data/DevHive.Data/Repositories/LanguageRepository.cs
@@ -26,8 +26,8 @@ namespace DevHive.Data.Repositories
}
/// <summary>
- /// Returns all technologies that exist in the database
- /// </summary>
+ /// Returns all technologies that exist in the database
+ /// </summary>
public HashSet<Language> GetLanguages()
{
return this._context.Languages.ToHashSet();
diff --git a/src/Data/DevHive.Data/Repositories/PostRepository.cs b/src/Data/DevHive.Data/Repositories/PostRepository.cs
index d35c475..b6c5e37 100644
--- a/src/Data/DevHive.Data/Repositories/PostRepository.cs
+++ b/src/Data/DevHive.Data/Repositories/PostRepository.cs
@@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
- public class PostRepository : BaseRepository<Post>, IPostRepository
+ public class PostRepository : BaseRepository<Post>, IPostRepository
{
private readonly DevHiveContext _context;
private readonly IUserRepository _userRepository;
@@ -41,8 +41,8 @@ namespace DevHive.Data.Repositories
}
/// <summary>
- /// This method returns the post that is made at exactly the given time and by the given creator
- /// </summary>
+ /// This method returns the post that is made at exactly the given time and by the given creator
+ /// </summary>
public async Task<Post> GetPostByCreatorAndTimeCreatedAsync(Guid creatorId, DateTime timeCreated)
{
return await this._context.Posts
@@ -68,12 +68,12 @@ namespace DevHive.Data.Repositories
.SetValues(newEntity);
List<PostAttachments> postAttachments = new();
- foreach(var attachment in newEntity.Attachments)
+ foreach (var attachment in newEntity.Attachments)
postAttachments.Add(attachment);
post.Attachments = postAttachments;
post.Comments.Clear();
- foreach(var comment in newEntity.Comments)
+ foreach (var comment in newEntity.Comments)
post.Comments.Add(comment);
// post.Rating.Id = ratingId;
diff --git a/src/Data/DevHive.Data/Repositories/TechnologyRepository.cs b/src/Data/DevHive.Data/Repositories/TechnologyRepository.cs
index 8cb7da1..d0d1f3f 100644
--- a/src/Data/DevHive.Data/Repositories/TechnologyRepository.cs
+++ b/src/Data/DevHive.Data/Repositories/TechnologyRepository.cs
@@ -26,8 +26,8 @@ namespace DevHive.Data.Repositories
}
/// <summary>
- /// Returns all technologies that exist in the database
- /// </summary>
+ /// Returns all technologies that exist in the database
+ /// </summary>
public HashSet<Technology> GetTechnologies()
{
return this._context.Technologies.ToHashSet();
diff --git a/src/DevHive.code-workspace b/src/DevHive.code-workspace
index 36e1700..8511609 100644
--- a/src/DevHive.code-workspace
+++ b/src/DevHive.code-workspace
@@ -31,7 +31,6 @@
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true,
"prettier.useEditorConfig": true,
- "workbench.editor.labelFormat": "short"
},
"launch": {
"configurations": [
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<Guid> 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
/// <summary>
/// This method is used in the feed page.
/// See the FeedRepository "GetFriendsPosts" menthod for more information on how it works.
- /// </summary>
+ /// </summary>
public async Task<ReadPageServiceModel> GetPage(GetPageServiceModel model)
{
User user = null;
@@ -58,7 +58,7 @@ namespace DevHive.Services.Services
/// <summary>
/// This method is used in the profile pages.
/// See the FeedRepository "GetUsersPosts" menthod for more information on how it works.
- /// </summary>
+ /// </summary>
public async Task<ReadPageServiceModel> 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
/// <summary>
- /// Checks whether the user Id in the token and the given user Id match
- /// </summary>
+ /// Checks whether the user Id in the token and the given user Id match
+ /// </summary>
public async Task<bool> ValidateJwtForCreating(Guid userId, string rawTokenData)
{
User user = await this.GetUserForValidation(rawTokenData);
@@ -154,10 +154,10 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// 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
- /// </summary>
+ /// </summary>
public async Task<bool> ValidateJwtForPost(Guid postId, string rawTokenData)
{
Post post = await this._postRepository.GetByIdAsync(postId) ??
@@ -175,10 +175,10 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// 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
- /// </summary>
+ /// </summary>
public async Task<bool> ValidateJwtForComment(Guid commentId, string rawTokenData)
{
Comment comment = await this._commentRepository.GetByIdAsync(commentId) ??
@@ -196,8 +196,8 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// Returns the user, via their Id in the token
- /// </summary>
+ /// Returns the user, via their Id in the token
+ /// </summary>
private async Task<User> GetUserForValidation(string rawTokenData)
{
JwtSecurityToken jwt = new JwtSecurityTokenHandler().ReadJwtToken(rawTokenData.Remove(0, 7));
@@ -212,8 +212,8 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// Returns all values from a given claim type
- /// </summary>
+ /// Returns all values from a given claim type
+ /// </summary>
private List<string> GetClaimTypeValues(string type, IEnumerable<Claim> claims)
{
List<string> 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
/// <summary>
- /// 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)
- /// </summary>
+ /// </summary>
public async Task<TokenModel> LoginUser(LoginServiceModel loginModel)
{
if (!await this._userRepository.DoesUsernameExistAsync(loginModel.UserName))
@@ -71,8 +71,8 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// Returns a new JSON Web Token (that can be used for authorization) for the given user
- /// </summary>
+ /// Returns a new JSON Web Token (that can be used for authorization) for the given user
+ /// </summary>
public async Task<TokenModel> RegisterUser(RegisterServiceModel registerModel)
{
if (await this._userRepository.DoesUsernameExistAsync(registerModel.UserName))
@@ -143,8 +143,8 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// Uploads the given picture and assigns it's link to the user in the database
- /// </summary>
+ /// Uploads the given picture and assigns it's link to the user in the database
+ /// </summary>
public async Task<ProfilePictureServiceModel> UpdateProfilePicture(UpdateProfilePictureServiceModel updateProfilePictureServiceModel)
{
User user = await this._userRepository.GetByIdAsync(updateProfilePictureServiceModel.UserId);
@@ -183,10 +183,10 @@ namespace DevHive.Services.Services
#region Validations
/// <summary>
- /// 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
- /// </summary>
+ /// </summary>
public async Task<bool> ValidJWT(Guid id, string rawTokenData)
{
// There is authorization name in the beginning, i.e. "Bearer eyJh..."
@@ -220,8 +220,8 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// Returns all values from a given claim type
- /// </summary>
+ /// Returns all values from a given claim type
+ /// </summary>
private List<string> GetClaimTypeValues(string type, IEnumerable<Claim> claims)
{
List<string> toReturn = new();
@@ -234,10 +234,10 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// 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
- /// </summary>
+ /// </summary>
private async Task ValidateUserOnUpdate(UpdateUserServiceModel updateUserServiceModel)
{
if (!await this._userRepository.DoesUserExistAsync(updateUserServiceModel.Id))
@@ -259,9 +259,9 @@ namespace DevHive.Services.Services
}
/// <summary>
- /// 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.
- /// </summary>
+ /// </summary>
private string WriteJWTSecurityToken(Guid userId, string username, HashSet<Role> roles)
{
byte[] signingKey = Encoding.ASCII.GetBytes(_jwtOptions.Secret);
diff --git a/src/Web/DevHive.Web.Tests/PostController.Tests.cs b/src/Web/DevHive.Web.Tests/PostController.Tests.cs
index 3a4e45e..96b0356 100644
--- a/src/Web/DevHive.Web.Tests/PostController.Tests.cs
+++ b/src/Web/DevHive.Web.Tests/PostController.Tests.cs
@@ -12,7 +12,7 @@ using NUnit.Framework;
namespace DevHive.Web.Tests
{
- [TestFixture]
+ [TestFixture]
public class PostControllerTests
{
const string MESSAGE = "Gosho Trapov";
diff --git a/src/Web/DevHive.Web.Tests/RoleController.Tests.cs b/src/Web/DevHive.Web.Tests/RoleController.Tests.cs
index 8e33bee..64e3f11 100644
--- a/src/Web/DevHive.Web.Tests/RoleController.Tests.cs
+++ b/src/Web/DevHive.Web.Tests/RoleController.Tests.cs
@@ -12,7 +12,7 @@ using NUnit.Framework;
namespace DevHive.Web.Tests
{
- [TestFixture]
+ [TestFixture]
public class RoleControllerTests
{
const string NAME = "Gosho Trapov";
diff --git a/src/Web/DevHive.Web.Tests/UserController.Tests.cs b/src/Web/DevHive.Web.Tests/UserController.Tests.cs
index efdfdbb..7457ad7 100644
--- a/src/Web/DevHive.Web.Tests/UserController.Tests.cs
+++ b/src/Web/DevHive.Web.Tests/UserController.Tests.cs
@@ -12,7 +12,7 @@ using NUnit.Framework;
namespace DevHive.Web.Tests
{
- [TestFixture]
+ [TestFixture]
public class UserControllerTests
{
const string USERNAME = "Gosho Trapov";