initial load
This commit is contained in:
@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YouTubeViewers.Domain.Models;
|
||||
using YouTubeViewers.Domain.Queries;
|
||||
using YouTubeViewers.EntityFramework.DTOs;
|
||||
|
||||
namespace YouTubeViewers.EntityFramework.Queries
|
||||
{
|
||||
public class GetAllYouTubeViewersQuery : IGetAllYouTubeViewersQuery
|
||||
{
|
||||
private readonly YouTubeViewersDbContextFactory _contextFactory;
|
||||
|
||||
public GetAllYouTubeViewersQuery(YouTubeViewersDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<YouTubeViewer>> Execute()
|
||||
{
|
||||
using (YouTubeViewersDbContext context = _contextFactory.Create())
|
||||
{
|
||||
//await Task.Delay(5000);
|
||||
|
||||
IEnumerable<YouTubeViewerDto> youTubeViewerDtos = await context.YouTubeViewers.ToListAsync();
|
||||
|
||||
return youTubeViewerDtos.Select(y => new YouTubeViewer(y.Id, y.Username, y.IsSubscribed, y.IsMember));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user