aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Data/Repositories/TechnologyRepository.cs
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-01-21 20:53:13 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-01-21 20:53:13 +0200
commitbd67366f41a25e868053bf3c71ed2917f25a8a6f (patch)
treea5754fcf564b09a42f884a58d2fd707e44ab8044 /src/DevHive.Data/Repositories/TechnologyRepository.cs
parent5e5e2eb2edef88840edbb072597f81f8da3ae929 (diff)
parent78884a445ec3f21d06e5859d03009b7d71bbb784 (diff)
downloadDevHive-bd67366f41a25e868053bf3c71ed2917f25a8a6f.tar
DevHive-bd67366f41a25e868053bf3c71ed2917f25a8a6f.tar.gz
DevHive-bd67366f41a25e868053bf3c71ed2917f25a8a6f.zip
fixing edit methods in repos
Diffstat (limited to 'src/DevHive.Data/Repositories/TechnologyRepository.cs')
-rw-r--r--src/DevHive.Data/Repositories/TechnologyRepository.cs24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/DevHive.Data/Repositories/TechnologyRepository.cs b/src/DevHive.Data/Repositories/TechnologyRepository.cs
index 6853893..35ee567 100644
--- a/src/DevHive.Data/Repositories/TechnologyRepository.cs
+++ b/src/DevHive.Data/Repositories/TechnologyRepository.cs
@@ -18,11 +18,9 @@ namespace DevHive.Data.Repositories
}
#region Create
-
public async Task<bool> AddAsync(Technology entity)
{
- await this._context
- .Set<Technology>()
+ await this._context.Technologies
.AddAsync(entity);
return await this.SaveChangesAsync(this._context);
@@ -30,11 +28,9 @@ namespace DevHive.Data.Repositories
#endregion
#region Read
-
public async Task<Technology> GetByIdAsync(Guid id)
{
- return await this._context
- .Set<Technology>()
+ return await this._context.Technologies
.FindAsync(id);
}
public async Task<Technology> GetByNameAsync(string technologyName)
@@ -46,24 +42,18 @@ namespace DevHive.Data.Repositories
#endregion
#region Edit
- public async Task<bool> EditAsync(Technology entity)
+ public async Task<bool> EditAsync(Technology newEntity)
{
- Technology technology = await this._context.Technologies
- .FirstOrDefaultAsync(x => x.Id == entity.Id);
-
- this._context.Update(technology);
- this._context.Entry(entity).CurrentValues.SetValues(entity);
+ this._context.Technologies.Update(newEntity);
return await this.SaveChangesAsync(this._context);
}
#endregion
#region Delete
-
public async Task<bool> DeleteAsync(Technology entity)
{
- this._context
- .Set<Technology>()
+ this._context.Technologies
.Remove(entity);
return await this.SaveChangesAsync(this._context);
@@ -71,11 +61,9 @@ namespace DevHive.Data.Repositories
#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);
}