diff options
Diffstat (limited to 'src/DevHive.Data/Repositories/TechnologyRepository.cs')
| -rw-r--r-- | src/DevHive.Data/Repositories/TechnologyRepository.cs | 53 |
1 files changed, 4 insertions, 49 deletions
diff --git a/src/DevHive.Data/Repositories/TechnologyRepository.cs b/src/DevHive.Data/Repositories/TechnologyRepository.cs index 73827a7..83cc7aa 100644 --- a/src/DevHive.Data/Repositories/TechnologyRepository.cs +++ b/src/DevHive.Data/Repositories/TechnologyRepository.cs @@ -1,79 +1,34 @@ using System; using System.Threading.Tasks; -using DevHive.Common.Models.Misc; using DevHive.Data.Interfaces.Repositories; using DevHive.Data.Models; using Microsoft.EntityFrameworkCore; - namespace DevHive.Data.Repositories { - public class TechnologyRepository : ITechnologyRepository + public class TechnologyRepository : BaseRepository<Technology>, ITechnologyRepository { private readonly DevHiveContext _context; public TechnologyRepository(DevHiveContext context) + :base(context) { this._context = context; } - #region Create - - public async Task<bool> AddAsync(Technology entity) - { - await this._context - .Set<Technology>() - .AddAsync(entity); - - return await RepositoryMethods.SaveChangesAsync(this._context); - } - #endregion - #region Read - - public async Task<Technology> GetByIdAsync(Guid id) - { - return await this._context - .Set<Technology>() - .FindAsync(id); - } public async Task<Technology> GetByNameAsync(string technologyName) { return await this._context.Technologies + .AsNoTracking() .FirstOrDefaultAsync(x => x.Name == technologyName); } #endregion - #region Edit - - public async Task<bool> EditAsync(Technology newEntity) - { - this._context - .Set<Technology>() - .Update(newEntity); - - return await RepositoryMethods.SaveChangesAsync(this._context); - } - #endregion - - #region Delete - - public async Task<bool> DeleteAsync(Technology entity) - { - this._context - .Set<Technology>() - .Remove(entity); - - return await RepositoryMethods.SaveChangesAsync(this._context); - } - #endregion - #region Validations - public async Task<bool> DoesTechnologyNameExistAsync(string technologyName) { - return await this._context - .Set<Technology>() + return await this._context.Technologies .AsNoTracking() .AnyAsync(r => r.Name == technologyName); } |
