aboutsummaryrefslogtreecommitdiff
path: root/API/Database/UserDbRepository.cs
blob: a51e3a8a26d94b8bdecf2b2cff85fef6e62c33d3 (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
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Models.Interfaces.Database;
using Microsoft.EntityFrameworkCore;
using 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 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);
		}
	}
}