aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/Repositories/LanguageRepository.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/LanguageRepository.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/LanguageRepository.cs')
-rw-r--r--src/DevHive.Data/Repositories/LanguageRepository.cs50
1 files changed, 3 insertions, 47 deletions
diff --git a/src/DevHive.Data/Repositories/LanguageRepository.cs b/src/DevHive.Data/Repositories/LanguageRepository.cs
index e644fc4..d7ee609 100644
--- a/src/DevHive.Data/Repositories/LanguageRepository.cs
+++ b/src/DevHive.Data/Repositories/LanguageRepository.cs
@@ -1,75 +1,31 @@
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 LanguageRepository : ILanguageRepository
+ public class LanguageRepository : BaseRepository<Language>, ILanguageRepository
{
private readonly DevHiveContext _context;
public LanguageRepository(DevHiveContext context)
+ :base(context)
{
this._context = context;
}
- #region Create
-
- public async Task<bool> AddAsync(Language entity)
- {
- await this._context
- .Set<Language>()
- .AddAsync(entity);
-
- return await RepositoryMethods.SaveChangesAsync(this._context);
- }
- #endregion
-
#region Read
-
- public async Task<Language> GetByIdAsync(Guid id)
- {
- return await this._context
- .Set<Language>()
- .FindAsync(id);
- }
-
public async Task<Language> GetByNameAsync(string languageName)
{
return await this._context.Languages
+ .AsNoTracking()
.FirstOrDefaultAsync(x => x.Name == languageName);
}
#endregion
- #region Update
-
- public async Task<bool> EditAsync(Language newEntity)
- {
- this._context
- .Set<Language>()
- .Update(newEntity);
-
- return await RepositoryMethods.SaveChangesAsync(this._context);
- }
- #endregion
-
- #region Delete
-
- public async Task<bool> DeleteAsync(Language entity)
- {
- this._context
- .Set<Language>()
- .Remove(entity);
-
- return await RepositoryMethods.SaveChangesAsync(this._context);
- }
- #endregion
-
#region Validations
-
public async Task<bool> DoesLanguageNameExistAsync(string languageName)
{
return await this._context.Languages