From 98e17766b203734a1817eed94338e2d25f4395f7 Mon Sep 17 00:00:00 2001 From: transtrike Date: Sat, 13 Feb 2021 16:20:18 +0200 Subject: Project Restructure P.1 --- .../DevHive.Data/Interfaces/Models/IComment.cs | 16 ++++++++++++++++ .../DevHive.Data/Interfaces/Models/ILanguage.cs | 11 +++++++++++ src/Data/DevHive.Data/Interfaces/Models/IModel.cs | 9 +++++++++ src/Data/DevHive.Data/Interfaces/Models/IPost.cs | 22 ++++++++++++++++++++++ .../Interfaces/Models/IProfilePicture.cs | 13 +++++++++++++ src/Data/DevHive.Data/Interfaces/Models/IRating.cs | 14 ++++++++++++++ src/Data/DevHive.Data/Interfaces/Models/IRole.cs | 10 ++++++++++ .../DevHive.Data/Interfaces/Models/ITechnology.cs | 11 +++++++++++ src/Data/DevHive.Data/Interfaces/Models/IUser.cs | 21 +++++++++++++++++++++ .../Interfaces/Repositories/ICommentRepository.cs | 16 ++++++++++++++++ .../Interfaces/Repositories/IFeedRepository.cs | 13 +++++++++++++ .../Interfaces/Repositories/ILanguageRepository.cs | 17 +++++++++++++++++ .../Interfaces/Repositories/IPostRepository.cs | 19 +++++++++++++++++++ .../Interfaces/Repositories/IRatingRepository.cs | 13 +++++++++++++ .../Interfaces/Repositories/IRepository.cs | 21 +++++++++++++++++++++ .../Interfaces/Repositories/IRoleRepository.cs | 15 +++++++++++++++ .../Repositories/ITechnologyRepository.cs | 17 +++++++++++++++++ .../Interfaces/Repositories/IUserRepository.cs | 22 ++++++++++++++++++++++ 18 files changed, 280 insertions(+) create mode 100644 src/Data/DevHive.Data/Interfaces/Models/IComment.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Models/ILanguage.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Models/IModel.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Models/IPost.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Models/IProfilePicture.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Models/IRating.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Models/IRole.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Models/ITechnology.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Models/IUser.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/ILanguageRepository.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/IPostRepository.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/IRepository.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/IRoleRepository.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/ITechnologyRepository.cs create mode 100644 src/Data/DevHive.Data/Interfaces/Repositories/IUserRepository.cs (limited to 'src/Data/DevHive.Data/Interfaces') diff --git a/src/Data/DevHive.Data/Interfaces/Models/IComment.cs b/src/Data/DevHive.Data/Interfaces/Models/IComment.cs new file mode 100644 index 0000000..97c1578 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/IComment.cs @@ -0,0 +1,16 @@ +using System; +using DevHive.Data.Models; + +namespace DevHive.Data.Interfaces.Models +{ + public interface IComment : IModel + { + Post Post { get; set; } + + User Creator { get; set; } + + string Message { get; set; } + + DateTime TimeCreated { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Models/ILanguage.cs b/src/Data/DevHive.Data/Interfaces/Models/ILanguage.cs new file mode 100644 index 0000000..9eed09d --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/ILanguage.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using DevHive.Data.Models; + +namespace DevHive.Data.Interfaces.Models +{ + public interface ILanguage : IModel + { + string Name { get; set; } + HashSet Users { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Models/IModel.cs b/src/Data/DevHive.Data/Interfaces/Models/IModel.cs new file mode 100644 index 0000000..f903af3 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/IModel.cs @@ -0,0 +1,9 @@ +using System; + +namespace DevHive.Data.Interfaces.Models +{ + public interface IModel + { + Guid Id { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Models/IPost.cs b/src/Data/DevHive.Data/Interfaces/Models/IPost.cs new file mode 100644 index 0000000..712d955 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/IPost.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using DevHive.Data.Models; +using DevHive.Data.RelationModels; + +namespace DevHive.Data.Interfaces.Models +{ + public interface IPost : IModel + { + User Creator { get; set; } + + string Message { get; set; } + + DateTime TimeCreated { get; set; } + + List Comments { get; set; } + + // Rating Rating { get; set; } + + List Attachments { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Models/IProfilePicture.cs b/src/Data/DevHive.Data/Interfaces/Models/IProfilePicture.cs new file mode 100644 index 0000000..c3fcbea --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/IProfilePicture.cs @@ -0,0 +1,13 @@ +using System; +using DevHive.Data.Models; + +namespace DevHive.Data.Interfaces.Models +{ + public interface IProfilePicture : IModel + { + Guid UserId { get; set; } + User User { get; set; } + + string PictureURL { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Models/IRating.cs b/src/Data/DevHive.Data/Interfaces/Models/IRating.cs new file mode 100644 index 0000000..d1b968f --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/IRating.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; +using DevHive.Data.Models; + +namespace DevHive.Data.Interfaces.Models +{ + public interface IRating : IModel + { + // Post Post { get; set; } + + int Rate { get; set; } + + // HashSet UsersThatRated { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Models/IRole.cs b/src/Data/DevHive.Data/Interfaces/Models/IRole.cs new file mode 100644 index 0000000..c8b7068 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/IRole.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using DevHive.Data.Models; + +namespace DevHive.Data.Interfaces.Models +{ + public interface IRole + { + HashSet Users { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Models/ITechnology.cs b/src/Data/DevHive.Data/Interfaces/Models/ITechnology.cs new file mode 100644 index 0000000..153f75f --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/ITechnology.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using DevHive.Data.Models; + +namespace DevHive.Data.Interfaces.Models +{ + public interface ITechnology : IModel + { + string Name { get; set; } + HashSet Users { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Models/IUser.cs b/src/Data/DevHive.Data/Interfaces/Models/IUser.cs new file mode 100644 index 0000000..fcd741c --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Models/IUser.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using DevHive.Data.Models; +using DevHive.Data.RelationModels; + +namespace DevHive.Data.Interfaces.Models +{ + public interface IUser : IModel + { + string FirstName { get; set; } + + string LastName { get; set; } + + ProfilePicture ProfilePicture { get; set; } + + HashSet Languages { get; set; } + + HashSet Technologies { get; set; } + + HashSet Roles { get; set; } + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs new file mode 100644 index 0000000..267f251 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/ICommentRepository.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using DevHive.Data.Models; +using DevHive.Data.Repositories.Interfaces; + +namespace DevHive.Data.Interfaces.Repositories +{ + public interface ICommentRepository : IRepository + { + Task> GetPostComments(Guid postId); + + Task DoesCommentExist(Guid id); + Task GetCommentByIssuerAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated); + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs new file mode 100644 index 0000000..7262510 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/IFeedRepository.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using DevHive.Data.Models; + +namespace DevHive.Data.Interfaces.Repositories +{ + public interface IFeedRepository + { + Task> GetFriendsPosts(List friendsList, DateTime firstRequestIssued, int pageNumber, int pageSize); + Task> GetUsersPosts(User user, DateTime firstRequestIssued, int pageNumber, int pageSize); + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/ILanguageRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/ILanguageRepository.cs new file mode 100644 index 0000000..db2949a --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/ILanguageRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using DevHive.Data.Models; +using DevHive.Data.Repositories.Interfaces; + +namespace DevHive.Data.Interfaces.Repositories +{ + public interface ILanguageRepository : IRepository + { + HashSet GetLanguages(); + Task GetByNameAsync(string name); + + Task DoesLanguageExistAsync(Guid id); + Task DoesLanguageNameExistAsync(string languageName); + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/IPostRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/IPostRepository.cs new file mode 100644 index 0000000..9f7cf85 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/IPostRepository.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using DevHive.Data.Models; +using DevHive.Data.Repositories.Interfaces; + +namespace DevHive.Data.Interfaces.Repositories +{ + public interface IPostRepository : IRepository + { + Task AddNewPostToCreator(Guid userId, Post post); + + Task GetPostByCreatorAndTimeCreatedAsync(Guid issuerId, DateTime timeCreated); + Task> GetFileUrls(Guid postId); + + Task DoesPostExist(Guid postId); + Task DoesPostHaveFiles(Guid postId); + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs new file mode 100644 index 0000000..f77f301 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/IRatingRepository.cs @@ -0,0 +1,13 @@ +using System; +using System.Threading.Tasks; +using DevHive.Data.Models; +using DevHive.Data.Repositories.Interfaces; + +namespace DevHive.Data.Interfaces.Repositories +{ + public interface IRatingRepository : IRepository + { + Task GetRatingByPostId(Guid postId); + Task UserRatedPost(Guid userId, Guid postId); + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/IRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/IRepository.cs new file mode 100644 index 0000000..0d11cd3 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/IRepository.cs @@ -0,0 +1,21 @@ +using System; +using System.Threading.Tasks; + +namespace DevHive.Data.Repositories.Interfaces +{ + public interface IRepository + where TEntity : class + { + //Add Entity to database + Task AddAsync(TEntity entity); + + //Find entity by id + Task GetByIdAsync(Guid id); + + //Modify Entity from database + Task EditAsync(Guid id, TEntity newEntity); + + //Delete Entity from database + Task DeleteAsync(TEntity entity); + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/IRoleRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/IRoleRepository.cs new file mode 100644 index 0000000..e834369 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/IRoleRepository.cs @@ -0,0 +1,15 @@ +using System; +using System.Threading.Tasks; +using DevHive.Data.Models; +using DevHive.Data.Repositories.Interfaces; + +namespace DevHive.Data.Interfaces.Repositories +{ + public interface IRoleRepository : IRepository + { + Task GetByNameAsync(string name); + + Task DoesNameExist(string name); + Task DoesRoleExist(Guid id); + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/ITechnologyRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/ITechnologyRepository.cs new file mode 100644 index 0000000..9126bfc --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/ITechnologyRepository.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using DevHive.Data.Models; +using DevHive.Data.Repositories.Interfaces; + +namespace DevHive.Data.Interfaces.Repositories +{ + public interface ITechnologyRepository : IRepository + { + Task GetByNameAsync(string name); + HashSet GetTechnologies(); + + Task DoesTechnologyExistAsync(Guid id); + Task DoesTechnologyNameExistAsync(string technologyName); + } +} diff --git a/src/Data/DevHive.Data/Interfaces/Repositories/IUserRepository.cs b/src/Data/DevHive.Data/Interfaces/Repositories/IUserRepository.cs new file mode 100644 index 0000000..5ebe3d3 --- /dev/null +++ b/src/Data/DevHive.Data/Interfaces/Repositories/IUserRepository.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using DevHive.Data.Models; +using DevHive.Data.Repositories.Interfaces; + +namespace DevHive.Data.Interfaces.Repositories +{ + public interface IUserRepository : IRepository + { + //Read + Task GetByUsernameAsync(string username); + Task UpdateProfilePicture(Guid userId, string pictureUrl); + + //Validations + Task ValidateFriendsCollectionAsync(List usernames); + Task DoesEmailExistAsync(string email); + Task DoesUserExistAsync(Guid id); + Task DoesUsernameExistAsync(string username); + bool DoesUserHaveThisUsername(Guid id, string username); + } +} -- cgit v1.2.3