blob: 2363200858aa96e1079271e66e2a6165965cfbab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Data.Models.Interfaces.Database;
using DevHive.Data.Models;
using Microsoft.EntityFrameworkCore;
namespace DevHive.Data.Repositories
{
public class UserRepository : IRepository<User>
{
private readonly DbContext _context;
public UserRepository(DbContext context)
{
this._context = context;
}
/*
public User FindByUsername(string username)
{
return this._dbRepository.DbSet
.FirstOrDefault(usr => usr.UserName == username);
}
public bool DoesUsernameExist(string username)
{
return this._dbRepository.DbSet
.Any(x => x.UserName == username);
}
public bool DoesUserExist(Guid id)
{
return this._dbRepository.DbSet
.Any(x => x.Id == id);
}
public bool HasThisUsername(Guid id, string username)
{
return this._dbRepository.DbSet
.Any(x => x.Id == id &&
x.UserName == username);
} */
public async Task AddAsync(User entity)
{
await this._context
.Set<User>()
.AddAsync(entity);
await this._context.SaveChangesAsync();
}
public IEnumerable<User> Query(int count)
{
return this._context
.Set<User>()
.AsNoTracking()
.Take(count)
.AsEnumerable();
}
public Task<User> FindByIdAsync(Guid id)
{
throw new System.NotImplementedException();
}
public Task EditAsync(object id, User newEntity)
{
throw new System.NotImplementedException();
}
public Task DeleteAsync(object id)
{
throw new System.NotImplementedException();
}
}
}
|