Exemple #1
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));
        }
Exemple #2
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());
        }