namespace MyOffice.Data.Repositories.Users;

using MyOffice.Data.Models.Users;
using Repositories;
using Microsoft.EntityFrameworkCore;
using MyOffice.DbContext;

public class UserRepository : AppRepository<User>, IUserRepository
{
	public UserRepository(AppDbContext context) : base(context)
	{
	}

	public async Task<User?> GetUserAsync(Guid id)
	{
		return await GetBaseAsync(id);
	}

	public User? GetUser(Guid id)
	{
		return GetBase(id);
	}

	public async Task<User?> GetByUserUserNameAsync(string userName)
	{
		return await _context.Users.FirstOrDefaultAsync(x => x.UserName == userName);
	}

	public User? GetByUserUserName(string userName)
	{
		return _context.Users.FirstOrDefault(x => x.UserName == userName);
	}

	public int AddUser(User user)
	{
		return AddBase(user);
	}

	public int UpdateUser(User user)
	{
		return UpdateBase(user);
	}
}