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 --- src/DevHive.Data/Repositories/BaseRepository.cs | 59 ------------------------- 1 file changed, 59 deletions(-) delete mode 100644 src/DevHive.Data/Repositories/BaseRepository.cs (limited to 'src/DevHive.Data/Repositories/BaseRepository.cs') diff --git a/src/DevHive.Data/Repositories/BaseRepository.cs b/src/DevHive.Data/Repositories/BaseRepository.cs deleted file mode 100644 index ece372e..0000000 --- a/src/DevHive.Data/Repositories/BaseRepository.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Threading.Tasks; -using DevHive.Data.Repositories.Interfaces; -using Microsoft.EntityFrameworkCore; - -namespace DevHive.Data.Repositories -{ - public class BaseRepository : IRepository - where TEntity : class - { - private readonly DbContext _context; - - public BaseRepository(DbContext context) - { - this._context = context; - } - - public virtual async Task AddAsync(TEntity entity) - { - await this._context - .Set() - .AddAsync(entity); - - return await this.SaveChangesAsync(); - } - - public virtual async Task GetByIdAsync(Guid id) - { - return await this._context - .Set() - .FindAsync(id); - } - - public virtual async Task EditAsync(Guid id, TEntity newEntity) - { - var entry = this._context.Entry(newEntity); - if (entry.State == EntityState.Detached) - this._context.Attach(newEntity); - - entry.State = EntityState.Modified; - - return await this.SaveChangesAsync(); - } - - public virtual async Task DeleteAsync(TEntity entity) - { - this._context.Remove(entity); - - return await this.SaveChangesAsync(); - } - - public virtual async Task SaveChangesAsync() - { - int result = await _context.SaveChangesAsync(); - - return result >= 1; - } - } -} -- cgit v1.2.3