示例#1
0
        public async Task <IActionResult> PutOne(string slug, int id, [FromBody] CoinModel body)
        {
            await Db.Connection.OpenAsync();

            var query  = new CoinPostQuery(Db);
            var result = await query.FirstPostAsync(slug, id);

            if (result is null)
            {
                return(new NotFoundResult());
            }
            result.Slug   = body.Slug;
            result.Last   = body.Last;
            result.Max    = body.Max;
            result.Min    = body.Min;
            result.Buy    = body.Buy;
            result.Sell   = body.Sell;
            result.Open   = body.Open;
            result.Vol    = body.Vol;
            result.Trade  = body.Trade;
            result.Trades = body.Trades;
            result.Vwap   = body.Vwap;
            result.Money  = body.Money;
            result.Date   = body.Date;
            await result.UpdateAsync();

            return(new OkObjectResult(result));
        }
示例#2
0
        public async Task <IActionResult> DeleteAll(string slug)
        {
            await Db.Connection.OpenAsync();

            var query = new CoinPostQuery(Db);
            await query.DeleteAllAsync(slug);

            return(new OkResult());
        }
示例#3
0
        public async Task <IActionResult> GetLatest(string slug)
        {
            await Db.Connection.OpenAsync();

            var query  = new CoinPostQuery(Db);
            var result = await query.LatestPostsAsync(slug);

            return(new OkObjectResult(result));
        }
示例#4
0
        public async Task <IActionResult> GetResult(string slug)
        {
            await Db.Connection.OpenAsync();

            var query  = new CoinPostQuery(Db);
            var result = await query.AllPostsAsync(slug);

            if (result is null)
            {
                return(new NotFoundResult());
            }
            return(new OkObjectResult(result));
        }
示例#5
0
        public async Task <IActionResult> DeleteOne(string slug, int id)
        {
            await Db.Connection.OpenAsync();

            var query  = new CoinPostQuery(Db);
            var result = await query.FirstPostAsync(slug, id);

            if (result is null)
            {
                return(new NotFoundResult());
            }
            await result.DeleteAsync();

            return(new OkResult());
        }