Ichen Chhoeng ff0e97e36b blah
2025-11-17 11:25:33 +07:00

31 lines
801 B
C#

using khmereid_backend.Data;
using khmereid_backend.Models;
using Microsoft.EntityFrameworkCore;
namespace khmereid_backend.Services
{
public class UserService(AppDbContext context)
{
private readonly AppDbContext _context = context;
public async Task<bool> IsUserExistsAsync(string phone)
{
phone = phone.Trim();
return await _context.Users.AnyAsync(u => u.Phone == phone);
}
public async Task<User> CreateUserAsync(string phone, Guid identityId)
{
var user = new User
{
Phone = phone.Trim(),
IdentityId = identityId
};
_context.Users.Add(user);
await _context.SaveChangesAsync();
return user;
}
}
}