using Distribution.Data; using Microsoft.EntityFrameworkCore; namespace Distribution.Features.DriverProfile; public class DriverProfileRepository(AppDBContext context) : IDriverProfileRepository { public async Task GetByIdAsync(Guid id) => await context.DriverProfiles .Include(p => p.User) .FirstOrDefaultAsync(p => p.Id == id); public async Task GetByUserIdAsync(Guid userId) => await context.DriverProfiles .Include(p => p.User) .FirstOrDefaultAsync(p => p.FK_UserId == userId); public async Task> GetAllAsync(int page, int pageSize) => await context.DriverProfiles .Include(p => p.User) .Where(p => p.IsActive) .Skip((page - 1) * pageSize) .Take(pageSize) .ToListAsync(); public async Task GetCountAsync() => await context.DriverProfiles.CountAsync(p => p.IsActive); public async Task AddAsync(global::Distribution.Models.DriverProfile profile) => await context.DriverProfiles.AddAsync(profile); public void Update(global::Distribution.Models.DriverProfile profile) => context.DriverProfiles.Update(profile); public void Deactivate(global::Distribution.Models.DriverProfile profile) { profile.IsActive = false; context.DriverProfiles.Update(profile); } }