internal static void RejectDuplicateRecord <T>(this ISimpleRepo <T> repo, Func <T, bool> predicate, string field, T record, Func <T, int> idGetter = null) //where T : IDocumentDTO { var matches = repo.GetAll().Where(predicate); if (!matches.Any()) { return; } if (matches.Count() > 1) { throw DuplicateRecordsException .For(matches, field, record.ToString()); } if (matches.Count() == 1 && idGetter != null) { var recId = idGetter(record); var matchId = idGetter(matches.Single()); if (recId == matchId) { return; } } throw DuplicateRecordsException .For(matches, field, record.ToString()); }
protected override List <InactiveLeaseDTO> QueryItems(ISimpleRepo <InactiveLeaseDTO> db) { var items = db.GetAll().OrderByDescending(_ => _.DeactivatedDate).ToList(); Caption = $" Inactive Leases ({items.Count:N0}) "; return(items); }
protected override List <LeaseDTO> QueryItems(ISimpleRepo <LeaseDTO> db) { _postdDate = AppArgs.Collections.LastPostedDate(); var items = db.GetAll().OrderByDescending(_ => _.Id).ToList(); Caption = $" Active Leases ({items.Count:N0}) "; return(items); }
public void SetHost(List <AccountAllocation> listHost, BankAccountDTO bankAccount, ISimpleRepo <GLAccountDTO> glAcctsRepo) { _list = listHost; _bank = bankAccount; //todo: use .IncludeCashInBanks() _glAccts = glAcctsRepo?.GetAll(); _glAccts?.Insert(0, GLAccountDTO.CashInBank(_bank)); UpdateUILists(); }
private static void EditAndRecompute <T>(ITenantDBsDir dir, int secId, ISimpleRepo <T> repo) where T : LeaseDTO { foreach (var lse in repo.GetAll()) { if (lse.Stall.Section.Id != secId) { continue; } EditLease(lse, repo); dir.Balances.GetRepo(lse)?.RecomputeAll(); } }
private static void ProcessRequests(ISimpleRepo <FundRequestDTO> repo) { foreach (var req in repo.GetAll()) { if (IsBuggy(req, out AccountAllocation bdo1Alloc)) { FixBuggyAlloc(bdo1Alloc); if (!repo.Update(req)) { throw new Exception("Request Update failed"); } } } }
private static void ProcessLeases <T>(MainWindowVM2 main, ISimpleRepo <T> repo) where T : LeaseDTO { foreach (var lse in repo.GetAll()) { main.StartBeingBusy($"Verifying memos for [{lse.Id}] “{lse}”..."); var win = new LeaseBalAdjustmentsVM(lse, main); win.Show <LeaseBalAjsWindow>(false, true); //foreach (BalanceAdjustmentDTO byf in byfAdjs) // VerifyLeaseMemo(byf, conv, main.AppArgs); } }
public List <T> GetAll() => ToSortedList(_repo.GetAll());
protected virtual List <TDTO> QueryItems(ISimpleRepo <TDTO> db) => db.GetAll();
protected override List <CollectorDTO> QueryItems(ISimpleRepo <CollectorDTO> db) => db.GetAll().OrderBy(_ => _.Id).ToList();
private static LeaseDTO FindLeaseIn <T>(StallDTO stall, ISimpleRepo <T> repo) where T : LeaseDTO => repo.GetAll().FindLast(_ => _.Stall.Id == stall.Id);