Пример #1
0
        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();
        }
Пример #2
0
        public OrderDBRepository(PetshopContext context, IRepository <Pet> petService, IPersonRepository personService)
        {
            db = context;

            _prep  = petService;
            _psrep = personService;
        }
Пример #3
0
 public VendaService(PetshopContext db) : base(db)
 {
 }
 public OrderRepository(PetshopContext ctx)
 {
     _ctx = ctx;
 }
 public OwnerSQLRepository(PetshopContext context)
 {
     _context = context;
 }
Пример #6
0
 public PetRepository(PetshopContext ctx)
 {
     _ctx = ctx;
 }
 public OwnerRepository(PetshopContext ctx)
 {
     context = ctx;
 }
Пример #8
0
 public PromocaoProdServService(PetshopContext db) : base(db)
 {
 }
Пример #9
0
 public PetSQLRepository(PetshopContext context)
 {
     _context = context;
 }
Пример #10
0
 public PetDBRepository(PetshopContext context)
 {
     _ctx = context;
 }
Пример #11
0
 public VendaAvaliacaoService(PetshopContext db) : base(db)
 {
 }
Пример #12
0
 public BaseRepository(PetshopContext db)
 {
     Db    = db;
     DbSet = Db.Set <TEntity>();
 }
Пример #13
0
 public UsuarioEspecialidadeService(PetshopContext db) : base(db)
 {
 }
Пример #14
0
 public OwnerRepository(PetshopContext context)
 {
     _Context = context;
 }
Пример #15
0
 // Contexto da inteface do Job e Quartz
 public Task Execute(IJobExecutionContext context)
 {
     Db = new PetshopContext();
     ExisteAgendamentoDia().GetAwaiter().GetResult();
     return(null);
 }
Пример #16
0
 public FileRepository(PetshopContext petshopContext)
 {
     context = petshopContext;
 }
Пример #17
0
 public PetController(PetshopContext context)
 {
     _context = context;
 }
Пример #18
0
        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();
        }
Пример #19
0
 public PetCategoryRepository(PetshopContext petshopContext)
 {
     context = petshopContext;
 }
Пример #20
0
        public PersonDBRepository(PetshopContext context, IRepository<Address> addressService)
        {
            db = context;

            _arep = addressService;
        }
Пример #21
0
 public PetTypeDBRepository(PetshopContext context)
 {
     db = context;
 }
Пример #22
0
 public UserRepository(PetshopContext context)
 {
     db = context;
 }
Пример #23
0
 public ColourDBRepository(PetshopContext context)
 {
     db = context;
 }
Пример #24
0
 public AgendamentoService(PetshopContext db) : base(db)
 {
 }
Пример #25
0
        // 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();
        }
Пример #26
0
 public ProdutoService(PetshopContext db) : base(db)
 {
 }
Пример #27
0
 public UsuarioService(PetshopContext db) : base(db)
 {
 }
Пример #28
0
 public AnimalService(PetshopContext db) : base(db)
 {
 }
Пример #29
0
 public ClienteService(PetshopContext db) : base(db)
 {
 }
 public PetRepository(PetshopContext ctx, IOwnerRepository ownerRepository)
 {
     ownerRepo = ownerRepository;
     context   = ctx;
 }