Exemplo n.º 1
0
        /// <summary>
        /// Delete an image asynchronously
        /// </summary>
        /// <param name="id">ID of image to delete</param>
        /// <returns>Task</returns>
        public async Task DeleteAsync(int id)
        {
            Image image = await _context.Images.FindAsync(id);

            if (image != null)
            {
                _context.Remove(image);
                await _context.SaveChangesAsync();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save a comment asynchronously
        /// </summary>
        /// <param name="comment">Comment to be saved</param>
        /// <returns>Task</returns>
        public async Task SaveAsync(Comment comment)
        {
            await _context.Comments.AddAsync(comment);

            await _context.SaveChangesAsync();
        }