public async Task <ActionResult <IEnumerable <Account> > > Get( AccountTypeParameter type, ContractKindParameter kind, SelectParameter select, SortParameter sort, OffsetParameter offset, [Range(0, 10000)] int limit = 100) { #region validate if (sort != null && !sort.Validate("id", "balance", "firstActivity", "lastActivity", "numTransactions", "numContracts")) { return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed.")); } #endregion #region optimize if (kind?.Eq != null && type == null) { type = new AccountTypeParameter { Eq = 2 } } ; #endregion if (select == null) { return(Ok(await Accounts.Get(type, kind, sort, offset, limit))); } if (select.Values != null) { if (select.Values.Length == 1) { return(Ok(await Accounts.Get(type, kind, sort, offset, limit, select.Values[0]))); } else { return(Ok(await Accounts.Get(type, kind, sort, offset, limit, select.Values))); } } else { if (select.Fields.Length == 1) { return(Ok(await Accounts.Get(type, kind, sort, offset, limit, select.Fields[0]))); } else { return(Ok(new SelectionResponse { Cols = select.Fields, Rows = await Accounts.Get(type, kind, sort, offset, limit, select.Fields) })); } } }
public async Task <ActionResult <IEnumerable <Delegator> > > GetDelegators( [Address] string address, AccountTypeParameter type, Int64Parameter balance, Int32Parameter delegationLevel, SortParameter sort, OffsetParameter offset, [Range(0, 10000)] int limit = 100) { #region validate if (sort != null && !sort.Validate("balance", "delegationLevel")) { return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed.")); } #endregion return(Ok(await Accounts.GetDelegators(address, type, balance, delegationLevel, sort, offset, limit))); }
public Task <int> GetCount(AccountTypeParameter type, ContractKindParameter kind) { #region optimize if (type == null && kind == null) { return(Task.FromResult(State.GetState().AccountsCount)); } if (kind?.Eq != null && type == null) { type = new AccountTypeParameter { Eq = 2 } } ; #endregion return(Accounts.GetCount(type, kind)); }
public Task <int> GetCount( AccountTypeParameter type, ContractKindParameter kind, Int64Parameter balance, BoolParameter staked) { #region optimize if (type == null && kind == null && balance == null && staked == null) { return(Task.FromResult(State.Current.AccountsCount)); } if (kind?.Eq != null && type == null) { type = new AccountTypeParameter { Eq = 2 } } ; #endregion return(Accounts.GetCount(type, kind, balance, staked)); }
public async Task <ActionResult <IEnumerable <Account> > > Get( AccountTypeParameter type, ContractKindParameter kind, AccountParameter @delegate, Int64Parameter balance, BoolParameter staked, Int32Parameter lastActivity, SelectParameter select, SortParameter sort, OffsetParameter offset, [Range(0, 10000)] int limit = 100) { #region validate if (@delegate != null) { if (@delegate.Eqx != null) { return(new BadRequest($"{nameof(@delegate)}.eqx", "This parameter doesn't support .eqx mode.")); } if (@delegate.Nex != null) { return(new BadRequest($"{nameof(@delegate)}.nex", "This parameter doesn't support .nex mode.")); } if (@delegate.Eq == -1 || @delegate.In?.Count == 0) { return(Ok(Enumerable.Empty <Account>())); } } if (sort != null && !sort.Validate("id", "balance", "firstActivity", "lastActivity", "numTransactions", "numContracts")) { return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed.")); } #endregion #region optimize if (kind?.Eq != null && type == null) { type = new AccountTypeParameter { Eq = 2 } } ; #endregion if (select == null) { return(Ok(await Accounts.Get(type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit))); } if (select.Values != null) { if (select.Values.Length == 1) { return(Ok(await Accounts.Get(type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values[0]))); } else { return(Ok(await Accounts.Get(type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Values))); } } else { if (select.Fields.Length == 1) { return(Ok(await Accounts.Get(type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields[0]))); } else { return(Ok(new SelectionResponse { Cols = select.Fields, Rows = await Accounts.Get(type, kind, @delegate, balance, staked, lastActivity, sort, offset, limit, select.Fields) })); } } }