From 09c8fc48a6a49c3c36df69ba2747088ac652054b Mon Sep 17 00:00:00 2001 From: transtrike Date: Tue, 15 Dec 2020 10:23:46 +0200 Subject: Changed object to Guid in IRepository --- src/DevHive.Data/Repositories/IRepository.cs | 7 ++++--- src/DevHive.Data/Repositories/UserRepository.cs | 23 ++++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) (limited to 'src/DevHive.Data/Repositories') diff --git a/src/DevHive.Data/Repositories/IRepository.cs b/src/DevHive.Data/Repositories/IRepository.cs index 81a1a35..f9ad2c5 100644 --- a/src/DevHive.Data/Repositories/IRepository.cs +++ b/src/DevHive.Data/Repositories/IRepository.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -13,12 +14,12 @@ namespace Data.Models.Interfaces.Database IEnumerable Query(int count); //Find entity by id - Task FindByIdAsync(object id); + Task FindByIdAsync(Guid id); //Modify Entity from database - Task EditAsync(object id, TEntity newEntity); + Task EditAsync(Guid id, TEntity newEntity); //Delete Entity from database - Task DeleteAsync(object id); + Task DeleteAsync(Guid id); } } \ No newline at end of file diff --git a/src/DevHive.Data/Repositories/UserRepository.cs b/src/DevHive.Data/Repositories/UserRepository.cs index b884732..2363200 100644 --- a/src/DevHive.Data/Repositories/UserRepository.cs +++ b/src/DevHive.Data/Repositories/UserRepository.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -9,12 +10,11 @@ namespace DevHive.Data.Repositories { public class UserRepository : IRepository { - private readonly UserRepository _dbRepository; + private readonly DbContext _context; public UserRepository(DbContext context) - : base (context) { - this._dbRepository = new DbRepository(context); + this._context = context; } /* public User FindByUsername(string username) @@ -42,17 +42,26 @@ namespace DevHive.Data.Repositories x.UserName == username); } */ - public Task AddAsync(User entity) + public async Task AddAsync(User entity) { - throw new System.NotImplementedException(); + await this._context + .Set() + .AddAsync(entity); + + await this._context.SaveChangesAsync(); } public IEnumerable Query(int count) { - throw new System.NotImplementedException(); + return this._context + .Set() + .AsNoTracking() + .Take(count) + .AsEnumerable(); + } - public Task FindByIdAsync(object id) + public Task FindByIdAsync(Guid id) { throw new System.NotImplementedException(); } -- cgit v1.2.3