Ejemplo n.º 1
0
        public async Task <IActionResult> GetLatest()
        {
            await MySqlDatabase.Connection.OpenAsync();

            var query  = new CloudItemQuery(MySqlDatabase);
            var result = await query.LatestPostsAsync();

            return(new OkObjectResult(result));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> GetOne(int id)
        {
            await MySqlDatabase.Connection.OpenAsync();

            var query  = new CloudItemQuery(MySqlDatabase);
            var result = await query.FindOneAsync(id);

            await MySqlDatabase.Connection.CloseAsync();

            if (result is null)
            {
                return(new NotFoundResult());
            }
            return(new OkObjectResult(result));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> DeleteOne(int id)
        {
            await MySqlDatabase.Connection.OpenAsync();

            var query  = new CloudItemQuery(MySqlDatabase);
            var result = await query.FindOneAsync(id);

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

            await MySqlDatabase.Connection.CloseAsync();

            return(new OkResult());
        }