Beispiel #1
0
        public Owner CreateOwner(Owner owner)
        {
            var newOwner = _ctx.Add(owner);

            _ctx.SaveChanges();
            return(newOwner.Entity);
        }
        public PetType CreatePetType(PetType petType)
        {
            var newType = _ctx.Add(petType);

            _ctx.SaveChanges();
            return(newType.Entity);
        }
Beispiel #3
0
 public async Task Add(TbPetCategory t)
 {
     context.Add(t);
     await context.SaveChangesAsync();
 }
        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();
        }