aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/Repositories/TechnologyRepository.cs
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2021-01-21 22:13:16 +0200
committertranstrike <transtrike@gmail.com>2021-01-21 22:13:16 +0200
commit13a2ceda912f961a232c87236f1b29aa29bb6160 (patch)
tree59f8d2bf63b03bacc76f98114d2aed78e420ddcd /src/DevHive.Data/Repositories/TechnologyRepository.cs
parenta47ea20ab91017da53437f750ed8e0f939f5cdba (diff)
parentbda98b96433d7a9952524fab4ec65f96998b55de (diff)
downloadDevHive-13a2ceda912f961a232c87236f1b29aa29bb6160.tar
DevHive-13a2ceda912f961a232c87236f1b29aa29bb6160.tar.gz
DevHive-13a2ceda912f961a232c87236f1b29aa29bb6160.zip
Merge branch 'refactor_user_updating' into dev
Diffstat (limited to 'src/DevHive.Data/Repositories/TechnologyRepository.cs')
-rw-r--r--src/DevHive.Data/Repositories/TechnologyRepository.cs53
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);
}