using Govor.Core.Infrastructure.Extensions; using Govor.Core.Infrastructure.Validators; using Govor.Core.Models; using Govor.Core.Repositories; using Govor.Data.Repositories.Exceptions; using Microsoft.EntityFrameworkCore; namespace Govor.Data.Repositories; public class UsersRepository : IUsersRepository { private GovorDbContext _context; private IObjectValidator _validator; public UsersRepository(GovorDbContext context, IObjectValidator validator) { _context = context; _validator = validator; } public async Task> GetAll() { return await _context.Users .AsNoTracking() .Where(x => true) .ToListAsync(); } public async Task FindById(Guid id) { return await _context.Users .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == id) ?? throw new NotFoundByKeyException(id, "User with given id does not exist"); } public async Task> FindByRangeId(IEnumerable ids) { return await _context.Users .AsNoTracking() .Where(x => ids.Contains(x.Id)) .ToListOrThrowIfEmpty(new NotFoundByKeyException>(ids,"Users with given ids not found")); } public async Task> FindUsersByName(string username) { return await _context.Users .AsNoTracking() .Where(x => x.Username == username) .ToListOrThrowIfEmpty(new NotFoundByKeyException(username, "Users with given username not found")); } public async Task> FindByRangeUsername(IEnumerable usernames) { return await _context.Users .AsNoTracking() .Where(x => usernames.Contains(x.Username)) .ToListOrThrowIfEmpty(new NotFoundByKeyException>(usernames, "Users with given usernames not found")); } public Task> FindUsersByCreatedDate(DateOnly createdDate) { throw new NotImplementedException(); } public Task Add(User user) { throw new NotImplementedException(); } public Task Update(User user) { throw new NotImplementedException(); } public Task Remove(User user) { throw new NotImplementedException(); } public Task Remove(Guid userId) { throw new NotImplementedException(); } public Task Exists(User user) { throw new NotImplementedException(); } public Task ExistsById(Guid id) { throw new NotImplementedException(); } public Task ExistsUsername(string username) { throw new NotImplementedException(); } }