feat: add promotion suggestions for Shop PO processing

This commit is contained in:
2026-10-22 16:26:15 +05:30
parent 5b2b39b7bf
commit 33dc4adce2
5 changed files with 389 additions and 11 deletions
@@ -49,6 +49,18 @@ public class SchemeRepository(AppDBContext context) : ISchemeRepository
public async Task AddRedemptionAsync(Models.SchemeRedemption entity) =>
await context.SchemeRedemptions.AddAsync(entity);
public async Task<List<Models.SchemeRedemption>> GetRedemptionsByShopPOAsync(Guid shopPOId)
{
var list = await context.SchemeRedemptions.Include(r => r.Scheme).Where(r => r.FK_ShopPOId == shopPOId).ToListAsync();
// Rows added earlier in this unit of work are not in the database yet; rows removed are still there.
foreach (var added in context.SchemeRedemptions.Local.Where(r => r.FK_ShopPOId == shopPOId && !list.Contains(r)))
list.Add(added);
return list.Where(r => context.Entry(r).State != EntityState.Deleted).ToList();
}
public void RemoveRedemption(Models.SchemeRedemption entity) =>
context.SchemeRedemptions.Remove(entity);
public async Task<bool> HasRedemptionAsync(Guid schemeId, Guid shopPOId) =>
await context.SchemeRedemptions.AnyAsync(r => r.FK_SchemeId == schemeId && r.FK_ShopPOId == shopPOId);