using Distribution.Data; using Microsoft.EntityFrameworkCore; namespace Distribution.Features.Order; public class OrderRepository(AppDBContext context) : IOrderRepository { public async Task GetByIdAsync(Guid id) => await context.Orders.FindAsync(id); public async Task> GetAllAsync() => await context.Orders.ToListAsync(); public async Task AddAsync(Models.Order entity) => await context.Orders.AddAsync(entity); public void Update(Models.Order entity) => context.Orders.Update(entity); public void Remove(Models.Order entity) { entity.IsActive = false; context.Orders.Update(entity); } public async Task> GetItemsByOrderIdAsync(Guid orderId) => await context.OrderItems.Where(oi => oi.FK_OrderId == orderId).ToListAsync(); public async Task> GetByStoreIdAsync(Guid storeId) => await context.Orders.Where(o => o.FK_StoreId == storeId && o.IsActive).ToListAsync(); public async Task AddItemsAsync(IEnumerable items) => await context.OrderItems.AddRangeAsync(items); }