private static void SeedOrderProduct(AppContextDB context, bool isRunningIntegrationTests) { if (isRunningIntegrationTests) { if (!context.OrderProducts.Any()) { var order1 = context.Orders.FirstOrDefault(c => c.Id == 1); var order2 = context.Orders.FirstOrDefault(c => c.Id == 2); var order3 = context.Orders.FirstOrDefault(c => c.Id == 3); var product1 = context.Products.FirstOrDefault(c => c.Id == 1); var product2 = context.Products.FirstOrDefault(c => c.Id == 2); var product3 = context.Products.FirstOrDefault(c => c.Id == 3); var product4 = context.Products.FirstOrDefault(c => c.Id == 4); context.OrderProducts.AddRange(new OrderProduct[] { new OrderProduct { OrderId = order1.Id, ProductId = product2.Id, Quantity = 1 }, new OrderProduct { OrderId = order1.Id, ProductId = product3.Id, Quantity = 2 }, new OrderProduct { OrderId = order1.Id, ProductId = product4.Id, Quantity = 1 }, new OrderProduct { OrderId = order2.Id, ProductId = product2.Id, Quantity = 3 }, }); context.SaveChanges(); } } }
private static void SeedOrder(AppContextDB context, bool isRunningIntegrationTests) { if (isRunningIntegrationTests) { if (!context.Orders.Any()) { var user1 = context.Users.Include(u => u.Adresses).FirstOrDefault(c => c.Id == 1); var user2 = context.Users.Include(u => u.Adresses).FirstOrDefault(c => c.Id == 2); context.Orders.AddRange(new Order[] { new Order { Occurrence = new DateTime(2021, 2, 10), User = user1, Address = user1.Adresses.ToList()[0] }, new Order { Occurrence = new DateTime(2021, 2, 14), User = user1, Address = user1.Adresses.ToList()[1] }, new Order { Occurrence = new DateTime(2021, 3, 4), User = user1, Address = user1.Adresses.ToList()[0] }, new Order { Occurrence = new DateTime(2021, 3, 10), User = user2, Address = user2.Adresses.ToList()[0] }, new Order { Occurrence = new DateTime(2021, 4, 2), User = user2, Address = user2.Adresses.ToList()[0] }, }); context.SaveChanges(); } } }
private static void SeedAddres(AppContextDB context, bool isRunningIntegrationTests) { if (isRunningIntegrationTests) { if (!context.Adresses.Any()) { var user1 = context.Users.FirstOrDefault(u => u.Id == 1); var user2 = context.Users.FirstOrDefault(u => u.Id == 2); var user3 = context.Users.FirstOrDefault(u => u.Id == 3); context.Adresses.AddRange(new Address[] { new Address { User = user1, Name = "Meu endereço", Description = "Rua das Flores, 20", City = "Rio Claro", State = "SP", Country = "Brasil", ZipCode = "13500452", Type = AddressTypeEnum.Residential }, new Address { User = user1, Name = "Minha Empresa", Description = "Av. Central, 423", City = "Rio Claro", State = "SP", Country = "Brasil", ZipCode = "13500534", Type = AddressTypeEnum.Commercial }, new Address { User = user2, Name = "Em casa", Description = "Rua Trancredo Neves, 3255", City = "Americana", State = "SP", Country = "Brasil", ZipCode = "13453999", Type = AddressTypeEnum.Residential }, new Address { User = user2, Name = "Vizinho", Description = "Rua Trancredo Neves, 4002", City = "Americana", State = "SP", Country = "Brasil", ZipCode = "13453998", Type = AddressTypeEnum.Other }, new Address { User = user3, Name = "Casa", Description = "Av. Matarazao, 203", City = "Buzios", State = "RJ", Country = "Brasil", ZipCode = "09435244", Type = AddressTypeEnum.Residential }, }); context.SaveChanges(); } } }
public DownloadPersonalDataModel( UserManager <User> userManager, ILogger <DownloadPersonalDataModel> logger, AppContextDB context) { _userManager = userManager; _logger = logger; _context = context; }
private static void SeedMovement(AppContextDB context, bool isRunningIntegrationTests) { if (isRunningIntegrationTests) { if (!context.Movements.Any()) { var user1 = context.Users.FirstOrDefault(u => u.Id == 1); var user2 = context.Users.FirstOrDefault(u => u.Id == 2); var user3 = context.Users.FirstOrDefault(u => u.Id == 3); var order1 = context.Orders.FirstOrDefault(c => c.Id == 1); var order2 = context.Orders.FirstOrDefault(c => c.Id == 2); var order3 = context.Orders.FirstOrDefault(c => c.Id == 3); var productAccumulation = context.Products.FirstOrDefault(c => c.Partner.Id == 1 && c.DotType == ProductDotTypeEnum.Add); context.Movements.AddRange(new Movement[] { new Movement { User = user1, Occurrence = new DateTime(2021, 1, 2), Product = productAccumulation, Dots = 40000, DueDate = new DateTime(2021, 3, 2), Type = MovementTypeEnum.Accumulation }, new Movement { User = user1, Occurrence = new DateTime(2021, 2, 3), Product = productAccumulation, Dots = 45000, DueDate = new DateTime(2021, 4, 3), Type = MovementTypeEnum.Accumulation }, new Movement { User = user1, Occurrence = new DateTime(2021, 2, 10), Product = productAccumulation, Dots = -76500, DueDate = new DateTime(2021, 4, 3), Type = MovementTypeEnum.Rescue }, new Movement { User = user2, Occurrence = new DateTime(2020, 10, 15), Product = productAccumulation, Dots = 10000, DueDate = new DateTime(2021, 1, 15), Type = MovementTypeEnum.Accumulation }, new Movement { User = user2, Occurrence = new DateTime(2020, 12, 26), Product = productAccumulation, Dots = 30000, DueDate = new DateTime(2021, 2, 26), Type = MovementTypeEnum.Accumulation }, new Movement { User = user2, Occurrence = new DateTime(2021, 1, 15), Product = null, Dots = -10000, DueDate = null, Type = MovementTypeEnum.Expired }, new Movement { User = user2, Occurrence = new DateTime(2020, 1, 30), Product = productAccumulation, Dots = 30000, DueDate = new DateTime(2021, 2, 26), Type = MovementTypeEnum.Accumulation }, }); context.SaveChanges(); } } }
private static void SeedPartners(AppContextDB context, bool isRunningIntegrationTests) { if (isRunningIntegrationTests) { if (!context.Partners.Any()) { context.Partners.AddRange(new Partner[] { new Partner { CNPJ = "12345678901234", Name = "Itau Unibanco" }, new Partner { CNPJ = "41512432423555", Name = "Americanas" }, new Partner { CNPJ = "99995342344523", Name = "Azul Compania Aérea" }, }); context.SaveChanges(); } } }
private static void SeedUser(AppContextDB context, bool isRunningIntegrationTests) { if (!context.Users.Any()) { var crypoHelper = new CryptoHelper(); //Add just one admin user context.Users.AddRange(new User[] { new User { CPF = "32245766008", Name = "System Administrator", Email = "*****@*****.**", Password = crypoHelper.GenerateHash("NewPassAdmin"), Role = UserRoleEnum.Admin }, }); //Add others fake users only to Integration Tests scenarios if (isRunningIntegrationTests) { context.Users.AddRange(new User[] { new User { CPF = "99388926048", Name = "José da Silva", Email = "*****@*****.**", Password = crypoHelper.GenerateHash("senha99*"), Role = UserRoleEnum.Consumer }, new User { CPF = "61991251009", Name = "Carolina Alberta Nunes", Email = "*****@*****.**", Password = crypoHelper.GenerateHash("88pass*"), Role = UserRoleEnum.Consumer }, new User { CPF = "50651670012", Name = "Maria Luiza Cartoz", Email = "*****@*****.**", Password = crypoHelper.GenerateHash("pass55**"), Role = UserRoleEnum.Partner }, new User { CPF = "23272283013", Name = "Humberto Gartner", Email = "*****@*****.**", Password = crypoHelper.GenerateHash("Hub*dotz"), Role = UserRoleEnum.Admin }, }); } context.SaveChanges(); } }
private static void SeedProducts(AppContextDB context, bool isRunningIntegrationTests) { if (isRunningIntegrationTests) { if (!context.Products.Any()) { var partner1 = context.Partners.FirstOrDefault(u => u.Id == 1); var partner2 = context.Partners.FirstOrDefault(u => u.Id == 2); var partner3 = context.Partners.FirstOrDefault(u => u.Id == 2); context.Products.AddRange(new Product[] { new Product { Partner = partner1, SKU = "1324567895", Name = "Acumulo pontos", DotPrice = 1, DotType = ProductDotTypeEnum.Add }, new Product { Partner = partner2, SKU = "78945656465", Name = "Panela de aço", DotPrice = 1500, DotType = ProductDotTypeEnum.Remove }, new Product { Partner = partner2, SKU = "24312412333", Name = "Celular Moto G", DotPrice = 20000, DotType = ProductDotTypeEnum.Remove }, new Product { Partner = partner2, SKU = "24552342432", Name = "Pneu Aro 20", DotPrice = 35000, DotType = ProductDotTypeEnum.Remove }, new Product { Partner = partner3, SKU = "99848822344", Name = "Relogio de parede", DotPrice = 800, DotType = ProductDotTypeEnum.Remove }, new Product { Partner = partner3, SKU = "62235244235", Name = "Roteador Wifi", DotPrice = 7500, DotType = ProductDotTypeEnum.Remove } }); } context.SaveChanges(); } }
public AdvancedSearchController(AppContextDB context) { _context = context; }
public RoomController(AppContextDB context) { _context = context; }
public UserRepository(AppContextDB context) : base(context) { }
protected Repository(AppContextDB context) { Db = context; DbSet = Db.Set <TEntity>(); }
public HomeController(AppContextDB context) { _context = context; }
public UserController(AppContextDB context, UserManager <User> userManager) { _context = context; _userManager = userManager; }
public TransactionController(AppContextDB context) { _context = context; }
public WalletModel(UserManager <User> userManager, AppContextDB context) { _userManager = userManager; _context = context; }
public PictureController(AppContextDB context, IWebHostEnvironment environment) { _context = context; _environment = environment; }
public MovementRepository(AppContextDB context) : base(context) { }
public AddressRepository(AppContextDB context) : base(context) { }
public AmenityController(AppContextDB context) { _context = context; }
public BookmarkModel(UserManager <User> userManager, AppContextDB context) { _userManager = userManager; _context = context; }
public BookmarkController(AppContextDB context, string userId) { _context = context; _userId = userId; }
public AccommodationController(AppContextDB context, UserManager <User> userManager, IWebHostEnvironment environment) { _context = context; _userManager = userManager; _environment = environment; }