ac3f34e4f3
Added .gitignore, solution, and project files for .NET 10. Introduced AGENTS.md and PLAN.md for guidelines and planning. Implemented appsettings.json, launchSettings.json, and MySQL config. Created AppDBContext and all domain models with composite keys. Added IUnitOfWork and EFUnitOfWork. Structured feature folders for Region, Route, Vehicle, Store, Warehouse, and Order with DTOs, repositories, services, and controllers. Added initial EF Core migrations and sample HTTP request. Registered dependencies and enabled OpenAPI in development.
35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
using Distribution.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Distribution.Features.Order;
|
|
|
|
public class OrderRepository(AppDBContext context) : IOrderRepository
|
|
{
|
|
public async Task<Models.Order?> GetByIdAsync(Guid id) =>
|
|
await context.Orders.FindAsync(id);
|
|
|
|
public async Task<List<Models.Order>> 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<List<Models.OrderItem>> GetItemsByOrderIdAsync(Guid orderId) =>
|
|
await context.OrderItems.Where(oi => oi.FK_OrderId == orderId).ToListAsync();
|
|
|
|
public async Task<List<Models.Order>> GetByStoreIdAsync(Guid storeId) =>
|
|
await context.Orders.Where(o => o.FK_StoreId == storeId && o.IsActive).ToListAsync();
|
|
|
|
public async Task AddItemsAsync(IEnumerable<Models.OrderItem> items) =>
|
|
await context.OrderItems.AddRangeAsync(items);
|
|
}
|