示例#1
0
        public async Task <ActionResult <IEnumerable <BigMapUpdate> > > GetBigMapUpdates(
            Int32Parameter bigmap,
            StringParameter path,
            AccountParameter contract,
            BigMapTagsParameter tags,
            BigMapActionParameter action,
            JsonParameter value,
            Int32Parameter level,
            TimestampParameter timestamp,
            SortParameter sort,
            OffsetParameter offset,
            [Range(0, 10000)] int limit = 100,
            MichelineFormat micheline   = MichelineFormat.Json)
        {
            #region validate
            if (sort != null && !sort.Validate("id", "level"))
            {
                return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed."));
            }
            #endregion

            if (path == null && contract == null && tags == null)
            {
                return(Ok(await BigMaps.GetUpdates(bigmap, action, value, level, timestamp, sort, offset, limit, micheline)));
            }

            return(Ok(await BigMaps.GetUpdates(bigmap, path, contract, action, value, tags, level, timestamp, sort, offset, limit, micheline)));
        }
示例#2
0
        public async Task <IEnumerable <Statistics> > Get(
            StatisticsPeriod period,
            Int32Parameter cycle,
            Int32Parameter level,
            TimestampParameter timestamp,
            DateTimeParameter date,
            SortParameter sort,
            OffsetParameter offset,
            int limit,
            Symbols quote)
        {
            var sql = new SqlBuilder(@"SELECT * FROM ""Statistics""");

            if (period == StatisticsPeriod.Cyclic)
            {
                sql.Filter(@"""Cycle"" IS NOT NULL");
            }
            else if (period == StatisticsPeriod.Daily)
            {
                sql.Filter(@"""Date"" IS NOT NULL");
            }

            sql.Filter("Cycle", cycle)
            .Filter("Level", level)
            .Filter("Level", timestamp)
            .Filter("Date", date)
            .Take(sort, offset, limit, x => x switch
            {
                "level" => ("Level", "Level"),
                "cycle" => ("Cycle", "Cycle"),
                "date" => ("Date", "Date"),
                _ => ("Id", "Id")
            });
示例#3
0
 public async Task <IEnumerable <Constant> > Get(
     ExpressionParameter address,
     Int32Parameter creationLevel,
     TimestampParameter creationTime,
     AccountParameter creator,
     Int32Parameter refs,
     Int32Parameter size,
     SortParameter sort,
     OffsetParameter offset,
     int limit,
     int format)
 {
     var sql = new SqlBuilder(@"SELECT * FROM ""RegisterConstantOps""")
               .Filter(@"""Address"" IS NOT NULL")
               .Filter("Address", address)
               .Filter("Level", creationLevel)
               .Filter("Level", creationTime)
               .Filter("SenderId", creator)
               .Filter("Refs", refs)
               .Filter("StorageUsed", size)
               .Take(sort, offset, limit, x => x switch
     {
         "creationLevel" => ("Level", "Level"),
         "size" => ("StorageUsed", "StorageUsed"),
         "refs" => ("Refs", "Refs"),
         _ => ("Id", "Id")
     });
示例#4
0
        public async Task <ActionResult <IEnumerable <Constant> > > Get(
            ExpressionParameter address,
            Int32Parameter creationLevel,
            TimestampParameter creationTime,
            AccountParameter creator,
            Int32Parameter refs,
            Int32Parameter size,
            SelectParameter select,
            SortParameter sort,
            OffsetParameter offset,
            [Range(0, 10000)] int limit = 100,
            [Range(0, 2)] int format    = 0)
        {
            #region validate
            if (sort != null && !sort.Validate("creationLevel", "size", "refs"))
            {
                return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed."));
            }
            #endregion

            if (select == null)
            {
                return(Ok(await Constants.Get(address, creationLevel, creationTime, creator, refs, size, sort, offset, limit, format)));
            }

            if (select.Values != null)
            {
                if (select.Values.Length == 1)
                {
                    return(Ok(await Constants.Get(address, creationLevel, creationTime, creator, refs, size, sort, offset, limit, select.Values[0], format)));
                }
                else
                {
                    return(Ok(await Constants.Get(address, creationLevel, creationTime, creator, refs, size, sort, offset, limit, select.Values, format)));
                }
            }
            else
            {
                if (select.Fields.Length == 1)
                {
                    return(Ok(await Constants.Get(address, creationLevel, creationTime, creator, refs, size, sort, offset, limit, select.Fields[0], format)));
                }
                else
                {
                    return(Ok(new SelectionResponse
                    {
                        Cols = select.Fields,
                        Rows = await Constants.Get(address, creationLevel, creationTime, creator, refs, size, sort, offset, limit, select.Fields, format)
                    }));
                }
            }
        }
示例#5
0
        public async Task <ActionResult <IEnumerable <Statistics> > > Get(
            Int32Parameter level,
            TimestampParameter timestamp,
            SelectParameter select,
            SortParameter sort,
            OffsetParameter offset,
            [Range(0, 10000)] int limit = 100,
            Symbols quote = Symbols.None)
        {
            #region validate
            if (sort != null && !sort.Validate("id", "level", "cycle", "date"))
            {
                return(new BadRequest($"{nameof(sort)}", "Sorting by the specified field is not allowed."));
            }
            #endregion

            if (select == null)
            {
                return(Ok(await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, quote)));
            }

            if (select.Values != null)
            {
                if (select.Values.Length == 1)
                {
                    return(Ok(await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, select.Values[0], quote)));
                }
                else
                {
                    return(Ok(await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, select.Values, quote)));
                }
            }
            else
            {
                if (select.Fields.Length == 1)
                {
                    return(Ok(await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, select.Fields[0], quote)));
                }
                else
                {
                    return(Ok(new SelectionResponse
                    {
                        Cols = select.Fields,
                        Rows = await Statistics.Get(StatisticsPeriod.None, null, level, timestamp, null, sort, offset, limit, select.Fields, quote)
                    }));
                }
            }
        }