blob: 2e7b0bb2517bb65575be220df41f954c63ce1b07 (
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
|
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Data.Models.Interfaces.Database;
using Microsoft.EntityFrameworkCore;
using Data.Models.Classes;
namespace API.Database
{
public class UserDbRepository : DbRepository<User>
{
private readonly DbRepository<User> _dbRepository;
public UserDbRepository(DbContext context)
: base (context)
{
this._dbRepository = new DbRepository<User>(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(int id)
{
return this._dbRepository.DbSet
.Any(x => x.Id == id);
}
public bool HasThisUsername(int id, string username)
{
return this._dbRepository.DbSet
.Any(x => x.Id == id &&
x.UserName == username);
}
}
}
|