public ItemController(ItemContext context, StockContext stockContext, ActionResponse actionContext, LogContext logContext, SupplierContext supplierContext) { _context = context; _stockContext = stockContext; _actionContext = actionContext; _logContext = logContext; _supplierContext = supplierContext; }
private void SetupDatabase() { using (var context = new SupplierContext(options)) { var suppliers = DataHelper.GetDummySuppliers(3); context.AddRange(suppliers); context.SaveChanges(); } }
public void GetAll() { using (var context = new SupplierContext(options)) { var service = new SupplierService(context); var result = service.GetSuppliers().Result; Assert.AreEqual(context.Suppliers, result); } }
public void Post() { using (var context = new SupplierContext(options)) { var service = new SupplierService(context); var supplier = DataHelper.GetDummySupplier(); supplier.Id = Guid.NewGuid(); var result = service.InsertSupplier(supplier); Assert.AreEqual(4, context.Suppliers.Count()); } }
public async static Task SeedSupplierRegDB(SupplierContext supplierContext) { if (supplierContext.Companies.Any()) { return; } var company = new Company("CompanyA", new UF("SC"), new CNPJ("83841875000143"), new Guid("0822f500-edb6-400b-856d-b01d4a67695d")); supplierContext.Companies.Add(company); supplierContext.Companies.Add(new Company("CompanyB", new UF("RJ"), new CNPJ("38389185000140"), Guid.NewGuid())); supplierContext.Companies.Add(new Company("CompanyC", new UF("SP"), new CNPJ("27569276000141"), Guid.NewGuid())); supplierContext.Companies.Add(new Company("CompanyPR", new UF("PR"), new CNPJ("84730514000192"), new Guid("0b1b65bb-d799-47c4-876f-aafc4ae0b93e"))); await supplierContext.SaveChangesAsync(); supplierContext.Suppliers.Add(new Supplier("SupplierA", new CPFCNPJ("81777787000102"), null, company, Guid.NewGuid())); supplierContext.Suppliers.Add(new Supplier("SupplierB", new CPFCNPJ("95582539000102"), null, company, Guid.NewGuid())); await supplierContext.SaveChangesAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, SupplierContext context) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Supplier}/{action=Index}/{id?}"); }); DbInitializer.Initialize(context); }
public AreaRepository(SupplierContext dbContext) : base(dbContext) { }
public SuppliersController(SupplierContext context) { _context = context; }
public Repository(SupplierContext context) { Context = context; DbSet = context.Set <T>(); }
public ProductRepository(SupplierContext context) : base(context) { }
public SupplierRepository(SupplierContext context) : base(context) { }
public SupplierRepository(SupplierContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public CreateModel(SupplierContext context) { _context = context; }
public CompanyRepository(SupplierContext context) : base(context) { }
public static void Initialize(IServiceProvider serviceProvider) { using (var context = new SupplierContext( serviceProvider.GetRequiredService <DbContextOptions <SupplierContext> >())) { if (context.Suppliers.Any()) { return; // Data was already seeded } var emails = new List <Email> { new Email { Id = Guid.NewGuid(), EmailAddress = "*****@*****.**", IsPreferred = true }, new Email { Id = Guid.NewGuid(), EmailAddress = "*****@*****.**", IsPreferred = false } }; var phones = new List <Phone> { new Phone { Id = Guid.NewGuid(), PhoneNumber = "12341234", IsPreferred = true }, new Phone { Id = Guid.NewGuid(), PhoneNumber = "09870987", IsPreferred = false } }; var suppliers = new List <Supplier> { new Supplier { Id = Guid.NewGuid(), FirstName = "Spongebob", LastName = "Squarepants", Emails = new List <Email> { emails.First() }, Phones = new List <Phone> { phones.First() } }, new Supplier { Id = Guid.NewGuid(), FirstName = "Patrick", LastName = "Star", Emails = new List <Email> { emails.Skip(1).First() }, Phones = new List <Phone> { phones.Skip(1).First() } } }; context.Emails.AddRange(emails); context.Phones.AddRange(phones); context.Suppliers.AddRange(suppliers); context.SaveChanges(); } }
public BuyerDataAccess(SupplierContext context, IMapper mapper) { this.Context = context; Mapper = mapper; }
public FakeService(SupplierContext context) { _context = context; }
public SupplierController(SupplierContext context, ActionResponse actionContext, LogContext logContext) { _context = context; _actionContext = actionContext; _logContext = logContext; }
public AddressRepository(SupplierContext context) : base(context) { }
// Constructor injection public SupplierService(SupplierContext supplierContext) { _supplierContext = supplierContext; }
public AboutModel(SupplierContext context) { _context = context; }
public DetailsModel(SupplierContext context) { _context = context; }
public DeleteModel(SupplierContext context) { _context = context; }
public SupplierService(SupplierContext context) { _context = context; }
public GenericRepository(SupplierContext dbContext) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _dbSet = _dbContext.Set <T>(); }
public IndexModel(SupplierContext context) { _context = context; }
public SupplierPv(SupplierContext context) { _context = context; }
public EditModel(SupplierContext context) { _context = context; }