public static void SeedData(this AppOscarContext context, int qtdeRegistros = 10) { if (context.Usuarios.Any()) { return; } var usuariosFake = new Faker <User>("pt_BR") .RuleFor(p => p.nomeUsuario, f => f.Name.FullName()) .RuleFor(p => p.emailUsuario, (f, p) => f.Internet.Email(firstName: p.nomeUsuario)) .RuleFor(p => p.senhaUsuario, f => f.Internet.Password()) .Generate(qtdeRegistros); context.Usuarios.AddRange(usuariosFake); var filmesFake = new Faker <Filme>("pt_BR") .RuleFor(f => f.IdFilme, f => f.Random.Guid()) .RuleFor(f => f.NomeFilme, f => f.Hacker.Phrase()) .RuleFor(f => f.FilmePhotoUrl, f => f.Internet.Url()) .Generate(qtdeRegistros); context.Filmes.AddRange(filmesFake); var categoriasFake = new Faker <Categoria>("pt_BR") .RuleFor(c => c.IdCategoria, f => f.Random.Guid()) .RuleFor(c => c.NomeCategoria, f => f.Lorem.Sentence()) .RuleFor(c => c.PontosCategoria, f => f.Random.Int(0, 10)) .RuleFor(f => f.CategoriaPhotoUrl, f => f.Internet.Url()) .Generate(qtdeRegistros); context.Categorias.AddRange(categoriasFake); context.SaveChanges(); }
private void ApplyMigrationsToContext(AppOscarContext context) { if (!context.Database.IsInMemory()) { if (context.Database.GetPendingMigrations().Any()) { //Log.Warning("Foram identificadas Migrations pendentes, novas migrations serão aplicadas"); context.Database.Migrate(); } } }
public ListFilmesPorCategoriaHandler(ILogger <ListFilmesPorCategoriaHandler> logger, AppOscarContext context) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.context = context ?? throw new ArgumentNullException(nameof(context)); }
public ListVotosPorFilmeHandler(AppOscarContext context) { this.context = context ?? throw new ArgumentNullException(nameof(context)); }
public CreateVotoHandler(AppOscarContext context) { this.context = context ?? throw new ArgumentNullException(nameof(context)); }
public CreateParticipacaoHandler(ILogger <CreateParticipacaoHandler> logger, AppOscarContext context) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.context = context ?? throw new ArgumentNullException(nameof(context)); }
public UserController(AppOscarContext context) { this.context = context ?? throw new System.ArgumentNullException(nameof(context)); }
public TimeController(AppOscarContext context) { this.context = context ?? throw new ArgumentNullException(nameof(context)); }