public async Task <int> UpdateAliasAsync(int id, string name, string payeeName) { Payee payee = _context.GetPayees() .Where(p => p.Name == payeeName) .OrderByDescending(p => p.EffectiveFrom) .FirstOrDefault() ?? throw new NullModelException($"There is no payee named '{payeeName}'"); return(await UpdateAliasAsync(id, name, payee.ID)); }
public IQueryable <Payee> GetPayees(bool includeCategory = false, bool includeAliases = false, bool includeTransactions = false, bool currentOnly = true) { if (currentOnly) { var query = from payee in _context.GetPayees(includeCategory, includeAliases, includeTransactions) where payee.EffectiveFrom == _context.GetPayees(false, false, false).Where(p => p.Name == payee.Name).OrderByDescending(p => p.EffectiveFrom).First().EffectiveFrom select payee; return(query); } return(_context.GetPayees(includeCategory, includeAliases, includeTransactions)); }
public async Task <Payee> GetSinglePayeeAsync(int?id, bool includeAll = false) { if (id == null) { throw new NullIdException("No id specified"); } var payee = await _context.GetPayees(includeAll, includeAll).Extension().SingleOrDefaultAsync(p => p.ID == id); if (payee == null) { throw new IdNotFoundException($"No payee found for ID = {id}"); } return(payee); }