public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseCors("AllowSpecificOrigin"); if (env.IsDevelopment()) { using (IServiceScope scope = app.ApplicationServices.CreateScope()) { PetshopContext context = scope.ServiceProvider.GetRequiredService <PetshopContext>(); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); DbInitializer.Seed(context); } app.UseDeveloperExceptionPage(); } else { using (IServiceScope scope = app.ApplicationServices.CreateScope()) { PetshopContext context = scope.ServiceProvider.GetRequiredService <PetshopContext>(); context.Database.EnsureCreated(); } app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); }
public OrderDBRepository(PetshopContext context, IRepository <Pet> petService, IPersonRepository personService) { db = context; _prep = petService; _psrep = personService; }
public VendaService(PetshopContext db) : base(db) { }
public OrderRepository(PetshopContext ctx) { _ctx = ctx; }
public OwnerSQLRepository(PetshopContext context) { _context = context; }
public PetRepository(PetshopContext ctx) { _ctx = ctx; }
public OwnerRepository(PetshopContext ctx) { context = ctx; }
public PromocaoProdServService(PetshopContext db) : base(db) { }
public PetSQLRepository(PetshopContext context) { _context = context; }
public PetDBRepository(PetshopContext context) { _ctx = context; }
public VendaAvaliacaoService(PetshopContext db) : base(db) { }
public BaseRepository(PetshopContext db) { Db = db; DbSet = Db.Set <TEntity>(); }
public UsuarioEspecialidadeService(PetshopContext db) : base(db) { }
public OwnerRepository(PetshopContext context) { _Context = context; }
// Contexto da inteface do Job e Quartz public Task Execute(IJobExecutionContext context) { Db = new PetshopContext(); ExisteAgendamentoDia().GetAwaiter().GetResult(); return(null); }
public FileRepository(PetshopContext petshopContext) { context = petshopContext; }
public PetController(PetshopContext context) { _context = context; }
public void Init(PetshopContext psc) { psc.Database.EnsureCreated(); if (psc.pets.Any()) { psc.Database.ExecuteSqlCommand("DROP TABLE PETS"); psc.Database.EnsureCreated(); } psc.Add(new Pet() { Birthdate = DateTime.Parse("28-03-2019"), Name = "Sweetý", Color = "White", Price = 8000, race = Pet.Race.Fox, PreviousOwner = new Owner() { Name = "Tanketorsk" } }); psc.Add(new Pet() { Birthdate = DateTime.Parse("02-07-1996"), Name = "Frank", Color = "Black", Price = 80000, race = Pet.Race.Dog, PreviousOwner = new Owner() { Name = "Marcipan" }, SoldDate = DateTime.Parse("02-07-1997"), }); psc.Add(new Pet() { Birthdate = DateTime.Parse("04-09-2008"), Name = "Spot", Color = "White & Black", Price = 700, race = Pet.Race.Dog }); psc.Add(new Pet() { Birthdate = DateTime.Parse("01-01-2019"), Name = "Fireworks", Color = "Brown", Price = 7680, race = Pet.Race.Cat }); psc.Add(new Pet() { Birthdate = DateTime.Parse("28-03-2010"), Name = "Shoop", Color = "White", Price = 550, race = Pet.Race.Goat }); psc.Add(new Pet() { Birthdate = DateTime.Parse("28-03-2012"), Name = "SnowWhite", Color = "Snow-White", Price = 80, race = Pet.Race.Rabbit }); psc.Add(new Owner() { Name = "Tester" }); psc.Add(new Owner() { Name = "Lars" }); psc.Add(new Owner() { Name = "Peter" }); psc.Add(new Owner() { Name = "Jeppe" }); psc.Add(new Owner() { Name = "Lårs" }); psc.SaveChanges(); }
public PetCategoryRepository(PetshopContext petshopContext) { context = petshopContext; }
public PersonDBRepository(PetshopContext context, IRepository<Address> addressService) { db = context; _arep = addressService; }
public PetTypeDBRepository(PetshopContext context) { db = context; }
public UserRepository(PetshopContext context) { db = context; }
public ColourDBRepository(PetshopContext context) { db = context; }
public AgendamentoService(PetshopContext db) : base(db) { }
// This method will create and seed the database. public static void Initialize(PetshopContext context) { // Delete the database, if it already exists. I do this because an // existing database may not be compatible with the entity model, // if the entity model was changed since the database was created. context.Database.EnsureDeleted(); // Create the database, if it does not already exists. This operation // is necessary, if you don't use an in-memory database. context.Database.EnsureCreated(); if (context.Addresses.Any()) { return; // DB has been seeded } List <Address> addresses = new List <Address> { new Address { Street = "Jensvej", Number = 5, Letter = null, Floor = null, Side = null, ZipCode = 6700, City = "Jensbjerg" }, new Address { Street = "Global Avenue", Number = 66, Letter = "b", Floor = null, Side = null, ZipCode = 3322, City = "Gaby" }, new Address { Street = "Vegtable Street", Number = 49, Letter = "V", Floor = 42, Side = "MF", ZipCode = 2743, City = "Salatary" } }; context.Addresses.AddRange(addresses); List <Colour> colours = new List <Colour> { new Colour { Description = "Black" }, new Colour { Description = "Orange" }, new Colour { Description = "Grey" }, new Colour { Description = "White" } }; context.Colours.AddRange(colours); List <PetType> petTypes = new List <PetType> { new PetType { Type = "Dog" }, new PetType { Type = "Cat" }, new PetType { Type = "Goat" }, new PetType { Type = "Dreadnought" } }; context.PetTypes.AddRange(petTypes); byte[] passwordHash, passwordSalt; CreatePasswordHash("1234", out passwordHash, out passwordSalt); List <Person> persons = new List <Person> { new Person { Username = "******", PasswordHash = passwordHash, PasswordSalt = passwordSalt, IsAdmin = false, FirstName = "Jens", LastName = "Jensen", Address = addresses[0], Phone = 536736, Email = "*****@*****.**" }, new Person { Username = "******", PasswordHash = passwordHash, PasswordSalt = passwordSalt, IsAdmin = false, FirstName = "John", LastName = "Smith", Address = addresses[1], Phone = 66666666, Email = "*****@*****.**" }, new Person { Username = "******", PasswordHash = passwordHash, PasswordSalt = passwordSalt, IsAdmin = true, FirstName = "Wonda Bonda", LastName = "Sonda", Address = addresses[2], Phone = 432589, Email = "*****@*****.**" }, }; context.Persons.AddRange(persons); List <Pet> pets = new List <Pet> { new Pet { Name = "Mortis", BirthDate = new DateTime(), SoldDate = DateTime.Now, Colours = new List <PetColourRelation> { new PetColourRelation() { ColourId = colours[0].Id } }, Type = petTypes[3], PreviousOwner = persons[1], Price = 12000000.0 }, new Pet { Name = "Jaga", BirthDate = new DateTime(), SoldDate = DateTime.Now, Colours = new List <PetColourRelation> { new PetColourRelation() { ColourId = colours[1].Id }, new PetColourRelation() { ColourId = colours[2].Id } }, Type = petTypes[2], PreviousOwner = persons[1], Price = 10.0 }, new Pet { Name = "Macauley", BirthDate = new DateTime(), SoldDate = DateTime.Now, Colours = new List <PetColourRelation> { new PetColourRelation() { ColourId = colours[2].Id } }, Type = petTypes[2], PreviousOwner = persons[0], Price = 1300.0 }, new Pet { Name = "Leray", BirthDate = new DateTime(), SoldDate = DateTime.Now, Colours = new List <PetColourRelation> { new PetColourRelation() { ColourId = colours[3].Id } }, Type = petTypes[1], PreviousOwner = persons[1], Price = 533 }, new Pet { Name = "Guy", BirthDate = new DateTime(), SoldDate = DateTime.Now, Colours = new List <PetColourRelation> { new PetColourRelation() { ColourId = colours[2].Id }, new PetColourRelation() { ColourId = colours[1].Id } }, Type = petTypes[0], PreviousOwner = persons[2], Price = 153.53 }, new Pet { Name = "Fabia", BirthDate = new DateTime(), SoldDate = DateTime.Now, Colours = new List <PetColourRelation> { new PetColourRelation() { ColourId = colours[1].Id } }, Type = petTypes[0], PreviousOwner = persons[0], Price = 99333 }, }; context.Pets.AddRange(pets); Order order = new Order { Customer = persons[2], OrderDate = DateTime.Now, Price = 2000, Pets = new List <OrderPetRelation> { new OrderPetRelation { Pet = pets[0] } } }; context.Orders.AddRange(order); context.SaveChanges(); }
public ProdutoService(PetshopContext db) : base(db) { }
public UsuarioService(PetshopContext db) : base(db) { }
public AnimalService(PetshopContext db) : base(db) { }
public ClienteService(PetshopContext db) : base(db) { }
public PetRepository(PetshopContext ctx, IOwnerRepository ownerRepository) { ownerRepo = ownerRepository; context = ctx; }