Пример #1
0
        public async Task <ActionResult <IEnumerable <TodoRun> > > GetTodoRuns()
        {
            await Db.Connection.OpenAsync();

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

            JsonConvert.SerializeObject(result);
            return(new OkObjectResult(result));
        }
Пример #2
0
        public async Task <ActionResult <TodoUser> > GetTodoRuns(int id)
        {
            await Db.Connection.OpenAsync();

            var query  = new RunPostQuery(Db);
            var result = await query.FindOneAsync(id);

            JsonConvert.SerializeObject(result);
            if (result is null)
            {
                return(new NotFoundResult());
            }
            return(new OkObjectResult(result));
        }
Пример #3
0
        public async Task <IActionResult> PutTodoRuns(int id, [FromQuery] TodoRun todoRun)
        {
            await Db.Connection.OpenAsync();

            var query  = new RunPostQuery(Db);
            var result = await query.FindOneAsync(id);

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

            result.Id_run       = todoRun.Id_run;
            result.Score        = todoRun.Score;
            result.Date         = todoRun.Date;
            result.Id_character = todoRun.Id_character;

            await result.UpdateAsync();

            JsonConvert.SerializeObject(result);
            return(new OkObjectResult(result));
        }