using Microsoft.EntityFrameworkCore; using Renis.Database; using Renis.Database.Models; namespace Renis.Repositories; public class UserRepository(ApplicationContext db) : IUserRepository { private readonly ApplicationContext _db = db; public async Task AddUser(User user) { _db.Users.Add(user); return await Save(); } public async Task DeleteUser(User user) { _db.Users.Remove(user); return await Save(); } public async Task GetUserById(long id) { return await _db.Users.FirstOrDefaultAsync(x => x.Id == id); } public async Task GetUserByPhone(string phone) { return await _db.Users.FirstOrDefaultAsync(x => x.Phone == phone); } public IQueryable GetUsers() { return _db.Users.AsQueryable(); } public async Task Save() { return await _db.SaveChangesAsync() > 0; } public async Task UpdateUser(User user) { _db.Users.Update(user); return await Save(); } }