item mng with sync
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
using Distribution.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Distribution.Features.Uom;
|
||||
|
||||
public class UomRepository(AppDBContext context) : IUomRepository
|
||||
{
|
||||
public async Task<Models.Uom?> GetByIdAsync(Guid id) =>
|
||||
await context.Uoms.FindAsync(id);
|
||||
|
||||
public async Task<List<Models.Uom>> GetAllAsync() =>
|
||||
await context.Uoms.ToListAsync();
|
||||
|
||||
public async Task<Models.Uom?> GetByExternalErpIdAsync(int erpId) =>
|
||||
await context.Uoms.FirstOrDefaultAsync(u => u.ExternalErpId == erpId);
|
||||
|
||||
public async Task<bool> IsUsedByItemsAsync(Guid id) =>
|
||||
await context.Items.AnyAsync(i => i.FK_BaseUomId == id && i.IsActive) ||
|
||||
await context.UomConversions.AnyAsync(c => c.FK_FromUomId == id || c.FK_ToUomId == id);
|
||||
|
||||
public async Task AddAsync(Models.Uom entity) =>
|
||||
await context.Uoms.AddAsync(entity);
|
||||
|
||||
public void Update(Models.Uom entity) =>
|
||||
context.Uoms.Update(entity);
|
||||
|
||||
public void Remove(Models.Uom entity)
|
||||
{
|
||||
entity.IsActive = false;
|
||||
context.Uoms.Update(entity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user