public static void Initialize(IServiceProvider serviceProvider) { using (var context = new MvcTitleContext( serviceProvider.GetRequiredService < DbContextOptions <MvcTitleContext> >())) { if (context.User.Any()) { return; } var user = new User { Name = "Ryan", Email = "*****@*****.**" }; context.User.Add(user); context.SaveChanges(); if (context.Title.Any()) { return; } var csvImporter = new CsvImporter(); csvImporter.ImportTitles(context); } }
public TitlesController(MvcTitleContext context, ITitleRepository titleRepository, WebClient webClient) { _context = context; _titleRepository = titleRepository; _webClient = webClient; }
public void ImportTitles(MvcTitleContext context) { using (var reader = new StreamReader(@"C:\Users\Ryan\source\repos\MvcTitle\Models\netflix_titles.csv")) using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture)) { csv.Configuration.RegisterClassMap <TitleMap>(); var titles = csv.GetRecords <Title>(); foreach (var title in titles) { context.Title.Add(title); } context.SaveChanges(); } }
public TokensController(IConfiguration config, MvcTitleContext context) { _config = config; _context = context; }
public UserRepository(MvcTitleContext context, IHttpContextAccessor httpContextAccessor) { _context = context; _httpContextAccessor = httpContextAccessor; }
public UsersController(MvcTitleContext context, IUserRepository userRepository) { _context = context; _userRepository = userRepository; }
public TitlesMvcController(MvcTitleContext context, ITitleRepository titleRepository) { _context = context; _titleRepository = titleRepository; }
public TitleRepository(MvcTitleContext context) { _context = context; }