redo
This commit is contained in:
@@ -1,20 +1,22 @@
|
||||
using back.DataModels;
|
||||
using back.persistance.data.repositories.Abstracts;
|
||||
using MCVIngenieros.Transactional.Implementations.EntityFramework;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Transactional.Implementations.EntityFramework;
|
||||
|
||||
namespace back.persistance.data.repositories;
|
||||
|
||||
public class UserRepository(DataContext context) : ReadWriteRepository<User>(context), IUserRepository
|
||||
public class UserRepository(
|
||||
DataContext context
|
||||
) : ReadWriteRepository<User>(context), IUserRepository
|
||||
{
|
||||
public async Task<User?> GetByEmail(string email)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(email)) return null;
|
||||
return await Entities.FirstOrDefaultAsync(u => u.Email == email);
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -37,26 +39,29 @@ public class UserRepository(DataContext context) : ReadWriteRepository<User>(con
|
||||
public async Task<User?> Login(string email, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) return null;
|
||||
try
|
||||
try
|
||||
{
|
||||
return await Entities.FirstOrDefaultAsync(u => u.Email == email && u.Password == password);
|
||||
return await Entities
|
||||
.Include(u => u.Roles)
|
||||
.ThenInclude(r => r.Permissions)
|
||||
.FirstOrDefaultAsync(u => u.Email == email && u.Password == password);
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> ExistsByEmail(string email)
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(email)) return false;
|
||||
return await Entities.AnyAsync(u => u.Email == email);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user