diff options
| -rw-r--r-- | src/DevHive.Data/Repositories/BaseRepository.cs (renamed from src/DevHive.Common/Models/Data/RepositoryMethods.cs) | 8 | ||||
| -rw-r--r-- | src/DevHive.Data/Repositories/LanguageRepository.cs | 8 | ||||
| -rw-r--r-- | src/DevHive.Data/Repositories/PostRepository.cs | 14 | ||||
| -rw-r--r-- | src/DevHive.Data/Repositories/RoleRepository.cs | 8 | ||||
| -rw-r--r-- | src/DevHive.Data/Repositories/TechnologyRepository.cs | 8 | ||||
| -rw-r--r-- | src/DevHive.Data/Repositories/UserRepository.cs | 24 |
6 files changed, 35 insertions, 35 deletions
diff --git a/src/DevHive.Common/Models/Data/RepositoryMethods.cs b/src/DevHive.Data/Repositories/BaseRepository.cs index bfd057f..b0f0f3e 100644 --- a/src/DevHive.Common/Models/Data/RepositoryMethods.cs +++ b/src/DevHive.Data/Repositories/BaseRepository.cs @@ -1,15 +1,15 @@ using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; -namespace DevHive.Common.Models.Misc +namespace DevHive.Data.Repositories { - public static class RepositoryMethods + public class BaseRepository { - public static async Task<bool> SaveChangesAsync(DbContext context) + public async Task<bool> SaveChangesAsync(DbContext context) { int result = await context.SaveChangesAsync(); return result >= 1; } } -}
\ No newline at end of file +} diff --git a/src/DevHive.Data/Repositories/LanguageRepository.cs b/src/DevHive.Data/Repositories/LanguageRepository.cs index e644fc4..108b307 100644 --- a/src/DevHive.Data/Repositories/LanguageRepository.cs +++ b/src/DevHive.Data/Repositories/LanguageRepository.cs @@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore; namespace DevHive.Data.Repositories { - public class LanguageRepository : ILanguageRepository + public class LanguageRepository : BaseRepository, ILanguageRepository { private readonly DevHiveContext _context; @@ -24,7 +24,7 @@ namespace DevHive.Data.Repositories .Set<Language>() .AddAsync(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion @@ -52,7 +52,7 @@ namespace DevHive.Data.Repositories .Set<Language>() .Update(newEntity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion @@ -64,7 +64,7 @@ namespace DevHive.Data.Repositories .Set<Language>() .Remove(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion diff --git a/src/DevHive.Data/Repositories/PostRepository.cs b/src/DevHive.Data/Repositories/PostRepository.cs index c5e8569..db2c4af 100644 --- a/src/DevHive.Data/Repositories/PostRepository.cs +++ b/src/DevHive.Data/Repositories/PostRepository.cs @@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore; namespace DevHive.Data.Repositories { - public class PostRepository : IPostRepository + public class PostRepository : BaseRepository, IPostRepository { private readonly DevHiveContext _context; @@ -23,7 +23,7 @@ namespace DevHive.Data.Repositories .Set<Post>() .AddAsync(post); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> AddCommentAsync(Comment entity) @@ -32,7 +32,7 @@ namespace DevHive.Data.Repositories .Set<Comment>() .AddAsync(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } //Read @@ -71,7 +71,7 @@ namespace DevHive.Data.Repositories .Set<Post>() .Update(newPost); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> EditCommentAsync(Comment newEntity) @@ -80,7 +80,7 @@ namespace DevHive.Data.Repositories .Set<Comment>() .Update(newEntity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } //Delete @@ -90,7 +90,7 @@ namespace DevHive.Data.Repositories .Set<Post>() .Remove(post); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> DeleteCommentAsync(Comment entity) @@ -99,7 +99,7 @@ namespace DevHive.Data.Repositories .Set<Comment>() .Remove(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #region Validations diff --git a/src/DevHive.Data/Repositories/RoleRepository.cs b/src/DevHive.Data/Repositories/RoleRepository.cs index ca3fb8b..684fbd7 100644 --- a/src/DevHive.Data/Repositories/RoleRepository.cs +++ b/src/DevHive.Data/Repositories/RoleRepository.cs @@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore; namespace DevHive.Data.Repositories { - public class RoleRepository : IRoleRepository + public class RoleRepository : BaseRepository, IRoleRepository { private readonly DevHiveContext _context; @@ -23,7 +23,7 @@ namespace DevHive.Data.Repositories .Set<Role>() .AddAsync(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } //Read @@ -51,7 +51,7 @@ namespace DevHive.Data.Repositories .CurrentValues .SetValues(newEntity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } //Delete @@ -61,7 +61,7 @@ namespace DevHive.Data.Repositories .Set<Role>() .Remove(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> DoesNameExist(string name) diff --git a/src/DevHive.Data/Repositories/TechnologyRepository.cs b/src/DevHive.Data/Repositories/TechnologyRepository.cs index 73827a7..390ad3f 100644 --- a/src/DevHive.Data/Repositories/TechnologyRepository.cs +++ b/src/DevHive.Data/Repositories/TechnologyRepository.cs @@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore; namespace DevHive.Data.Repositories { - public class TechnologyRepository : ITechnologyRepository + public class TechnologyRepository : BaseRepository, ITechnologyRepository { private readonly DevHiveContext _context; @@ -25,7 +25,7 @@ namespace DevHive.Data.Repositories .Set<Technology>() .AddAsync(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion @@ -52,7 +52,7 @@ namespace DevHive.Data.Repositories .Set<Technology>() .Update(newEntity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion @@ -64,7 +64,7 @@ namespace DevHive.Data.Repositories .Set<Technology>() .Remove(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs index 6d4a0bf..81c974c 100644 --- a/src/DevHive.Data/Repositories/UserRepository.cs +++ b/src/DevHive.Data/Repositories/UserRepository.cs @@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore; namespace DevHive.Data.Repositories { - public class UserRepository : IUserRepository + public class UserRepository : BaseRepository, IUserRepository { private readonly DevHiveContext _context; @@ -25,7 +25,7 @@ namespace DevHive.Data.Repositories await this._context.Users .AddAsync(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> AddFriendToUserAsync(User user, User friend) @@ -33,7 +33,7 @@ namespace DevHive.Data.Repositories this._context.Update(user); user.Friends.Add(friend); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> AddLanguageToUserAsync(User user, Language language) @@ -42,7 +42,7 @@ namespace DevHive.Data.Repositories user.Languages.Add(language); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> AddTechnologyToUserAsync(User user, Technology technology) @@ -51,7 +51,7 @@ namespace DevHive.Data.Repositories user.Technologies.Add(technology); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion @@ -116,7 +116,7 @@ namespace DevHive.Data.Repositories .CurrentValues .SetValues(newEntity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> EditUserLanguageAsync(User user, Language oldLang, Language newLang) @@ -126,7 +126,7 @@ namespace DevHive.Data.Repositories user.Languages.Remove(oldLang); user.Languages.Add(newLang); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> EditUserTechnologyAsync(User user, Technology oldTech, Technology newTech) @@ -136,7 +136,7 @@ namespace DevHive.Data.Repositories user.Technologies.Remove(oldTech); user.Technologies.Add(newTech); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion @@ -147,7 +147,7 @@ namespace DevHive.Data.Repositories this._context.Users .Remove(entity); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> RemoveFriendAsync(User user, User friend) @@ -155,7 +155,7 @@ namespace DevHive.Data.Repositories this._context.Update(user); user.Friends.Remove(friend); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> RemoveLanguageFromUserAsync(User user, Language language) @@ -164,7 +164,7 @@ namespace DevHive.Data.Repositories user.Languages.Remove(language); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } public async Task<bool> RemoveTechnologyFromUserAsync(User user, Technology technology) @@ -173,7 +173,7 @@ namespace DevHive.Data.Repositories user.Technologies.Remove(technology); - return await RepositoryMethods.SaveChangesAsync(this._context); + return await this.SaveChangesAsync(this._context); } #endregion |
