private void Seed() { using var context = new DroneDbContext(ContextOptions); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); var usuario = Usuario.Criar("test", "*****@*****.**", -23.35566, -46.36554, UsuarioRole.Cliente); usuario.AdicionarPassword("123"); usuario.AdicionarRefreshToken("refreshtoken", DateTime.Now.AddDays(1)); context.Add(usuario); var drone1 = Drone.Criar(12000, 3, 35, 100, DroneStatus.Livre); var drone2 = Drone.Criar(10000, 4, 35, 50, DroneStatus.Livre); context.Add(drone1); context.Add(drone2); context.SaveChanges(); var pedido = Pedido.Criar(Guid.NewGuid(), 5000, 1000, usuario); var mongoContext = new DroneMongoDbContext(MongoOptions); mongoContext.Pedidos.InsertOne(pedido); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DroneDbContext context, IPasswordHasher <Usuario> passwordHasher, IGeradorToken geradorToken) { app.UseMiddleware(typeof(ErrorHandlerMiddleware)); if (env.IsDevelopment()) { //app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Drone Delivery Entrega V1"); c.RoutePrefix = string.Empty; }); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); Seed.Seed.SeedData(context, passwordHasher, geradorToken); }
public UnitOfWork(DroneDbContext context) { _context = context; Pedidos = new PedidoRepository(_context); Drones = new DroneRepository(_context); Usuarios = new UsuarioRepository(_context); }
public UnitOfWork(DroneDbContext context, DroneMongoDbContext contextMongo) { _context = context; _contextMongo = contextMongo; Pedidos = new PedidoRepository(_context, _contextMongo); Drones = new DroneRepository(_context, _contextMongo); Usuarios = new UsuarioRepository(_context); }
public static void SeedData(DroneDbContext context, IPasswordHasher <Usuario> passwordHasher, IGeradorToken geradorToken) { var admin = context.Usuarios.FirstOrDefault(x => (int)x.Role == (int)UsuarioRole.Admin); if (admin == null) { admin = Usuario.Criar("Admin", "*****@*****.**", -23.5753639, -46.645421, UsuarioRole.Admin); var passwordHash = passwordHasher.HashPassword(admin, "123"); admin.AdicionarPassword(passwordHash); var token = geradorToken.GerarRefreshToken(admin); admin.AdicionarRefreshToken(token.Token, token.DataExpiracao); context.Usuarios.Add(admin); context.SaveChanges(); } }
public DroneRepository(DroneDbContext context, DroneMongoDbContext contextMongo) { _context = context; _contextMongo = contextMongo; }
public DroneRepositoryTests() { _context = new DroneDbContext(ContextOptions); _droneRepository = new DroneRepository(_context); }
public PedidoRepository(DroneDbContext dbContext) { _context = dbContext; }
public PedidoRepositoryTests() { _context = new DroneDbContext(ContextOptions); _pedidoRepository = new PedidoRepository(_context); }
public UsuarioRepositoryTests() { _context = new DroneDbContext(ContextOptions); _usuarioRepository = new UsuarioRepository(_context); }
public PedidoRepositoryTests() { _context = new DroneDbContext(ContextOptions); _contextMongo = new DroneMongoDbContext(MongoOptions); _pedidoRepository = new PedidoRepository(_context, _contextMongo); }
public DroneRepository(DroneDbContext context) { _context = context; }
public UsuarioRepository(DroneDbContext context) { _context = context; }
public IntinerarioRepository(DroneDbContext context) { _context = context; }