From bda98b96433d7a9952524fab4ec65f96998b55de Mon Sep 17 00:00:00 2001 From: transtrike Date: Thu, 21 Jan 2021 22:08:50 +0200 Subject: Generic base repo class refactored; All repos inherit generic base repo --- .../Repositories/TechnologyRepository.cs | 39 ++-------------------- 1 file changed, 2 insertions(+), 37 deletions(-) (limited to 'src/DevHive.Data/Repositories/TechnologyRepository.cs') diff --git a/src/DevHive.Data/Repositories/TechnologyRepository.cs b/src/DevHive.Data/Repositories/TechnologyRepository.cs index 35ee567..83cc7aa 100644 --- a/src/DevHive.Data/Repositories/TechnologyRepository.cs +++ b/src/DevHive.Data/Repositories/TechnologyRepository.cs @@ -1,38 +1,22 @@ 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 : BaseRepository, ITechnologyRepository + public class TechnologyRepository : BaseRepository, ITechnologyRepository { private readonly DevHiveContext _context; public TechnologyRepository(DevHiveContext context) + :base(context) { this._context = context; } - #region Create - public async Task AddAsync(Technology entity) - { - await this._context.Technologies - .AddAsync(entity); - - return await this.SaveChangesAsync(this._context); - } - #endregion - #region Read - public async Task GetByIdAsync(Guid id) - { - return await this._context.Technologies - .FindAsync(id); - } public async Task GetByNameAsync(string technologyName) { return await this._context.Technologies @@ -41,25 +25,6 @@ namespace DevHive.Data.Repositories } #endregion - #region Edit - public async Task EditAsync(Technology newEntity) - { - this._context.Technologies.Update(newEntity); - - return await this.SaveChangesAsync(this._context); - } - #endregion - - #region Delete - public async Task DeleteAsync(Technology entity) - { - this._context.Technologies - .Remove(entity); - - return await this.SaveChangesAsync(this._context); - } - #endregion - #region Validations public async Task DoesTechnologyNameExistAsync(string technologyName) { -- cgit v1.2.3