mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 17:43:12 +00:00
37 lines
1,023 B
C#
37 lines
1,023 B
C#
using Data.SeaHavenIndustries;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using SeaHaven.DataServices.Interfaces;
|
|
|
|
namespace SeaHaven.DataServices.Implementation
|
|
{
|
|
public class UserDataService : IUserDataService
|
|
{
|
|
private readonly ApplicationDbContext _context;
|
|
|
|
public UserDataService(ApplicationDbContext context)
|
|
{
|
|
_context = context;
|
|
}
|
|
|
|
public async Task<ApplicationUser?> GetByIdAsync(string id)
|
|
{
|
|
return await _context.Users.FindAsync(id);
|
|
}
|
|
|
|
public async Task<IEnumerable<ApplicationUser>> GetAllAsync()
|
|
{
|
|
return await _context.Users.ToListAsync();
|
|
}
|
|
|
|
public async Task<ApplicationUser?> GetByEmailAsync(string email)
|
|
{
|
|
return await _context.Users
|
|
.FirstOrDefaultAsync(u => u.Email == email);
|
|
}
|
|
|
|
public async Task<bool> ExistsAsync(string id)
|
|
{
|
|
return await _context.Users.AnyAsync(u => u.Id == id);
|
|
}
|
|
}
|
|
}
|