public static void Main() { using var data = new PetStoreDbContext(); var userService = new UserSerice(data); var breedService = new BreedService(data); var categoryService = new CategoryService(data); var petService = new PetService(data, breedService, categoryService, userService); petService.BuyPet(Data.Models.Gender.Male, DateTime.Now, 0m, null, 1, 1); petService.SellPet(1, 1); }
private static void SeedData(PetStoreDbContext data) { var breedService = new BreedService(data); for (int i = 1; i < 10; i++) { breedService.Add("Breed " + i); } var categoryService = new CategoryService(data); for (int i = 1; i < 10; i++) { categoryService.Create("Category " + i); } var petService = new PetService(data, breedService, categoryService); for (int i = 0; i < 50; i++) { var breedId = data.Breeds .OrderBy(b => Guid.NewGuid()) .Select(b => b.Id) .FirstOrDefault(); var categoryId = data.Categories .OrderBy(c => Guid.NewGuid()) .Select(c => c.Id) .FirstOrDefault(); petService.BuyPet(new Pet() { BreedId = breedId, CategoryId = categoryId, DateOfBirth = DateTime.Now.AddDays(2 * i), Gender = (Gender)(i % 2), Price = 10 + 3 * i }); } var brandService = new BrandService(data); for (int i = 1; i < 10; i++) { brandService.Add("Brand " + i); } data.SaveChanges(); }
public static void Main() { using var data = new PetStoreDbContext(); data.Database.Migrate(); // Services var brandService = new BrandService(data); var breedService = new BreedService(data); var categoryService = new CategoryService(data); var userService = new UserService(data); var foodService = new FoodService(data, userService); var petService = new PetService(data, categoryService, breedService, userService); var toyService = new ToyService(data, userService); brandService.Create("Whiskas"); brandService.Create("9Lives"); brandService.Create("Friskies"); brandService.Create("Halo"); breedService.Add("Abyssian"); breedService.Add("Birman"); breedService.Add("Bengal"); breedService.Add("Chartreux"); categoryService.Add("Cat", "A cat is some cute animal"); categoryService.Add("Dog", "The dog is another cute animal"); categoryService.Add("Whale"); categoryService.Add("Parrot"); foodService.BuyFromDistributor("Meaty Bits", 156, 2, 3.50m, DateTime.Now.AddDays(30), brandService.GetIdByName("Friskies"), categoryService.GetIdByName("Cat")); foodService.BuyFromDistributor("Meaty Nuggets", 400, 3, 5.75m, DateTime.Now.AddDays(60), brandService.GetIdByName("Whiskas"), categoryService.GetIdByName("Cat")); foodService.BuyFromDistributor("Hearty Cuts", 168, 3, 1.75m, DateTime.Now.AddDays(42), brandService.GetIdByName("9Lives"), categoryService.GetIdByName("Cat")); foodService.BuyFromDistributor("Holistic Chicken", 149, 2, 2.75m, DateTime.Now.AddDays(15), brandService.GetIdByName("Halo"), categoryService.GetIdByName("Cat")); userService.Register("Atanas Kolev", "*****@*****.**"); userService.Register("Daniel Ivanov", "*****@*****.**"); userService.Register("Georgi Petrov", "*****@*****.**"); userService.Register("Ivan Panagonov", "*****@*****.**"); foodService.SellFoodToUser(foodService.GetIdByName("Meaty Bits"), userService.GetIdByName("Atanas Kolev")); foodService.SellFoodToUser(foodService.GetIdByName("Meaty Nuggets"), userService.GetIdByName("Daniel Ivanov")); foodService.SellFoodToUser(foodService.GetIdByName("Hearty Cuts"), userService.GetIdByName("Georgi Petrov")); foodService.SellFoodToUser(foodService.GetIdByName("Holistic Chicken"), userService.GetIdByName("Ivan Panagonov")); petService.BuyPet(Gender.Male, DateTime.Now.AddDays(-90), 350, "", breedService.GetIdByName("Abyssian"), categoryService.GetIdByName("Cat")); petService.BuyPet(Gender.Female, DateTime.Now.AddDays(-476), 400, "Female cat...", breedService.GetIdByName("Birman"), categoryService.GetIdByName("Cat")); petService.BuyPet(Gender.Female, DateTime.Now.AddDays(-90), 350, "Another female cat", breedService.GetIdByName("Bengal"), categoryService.GetIdByName("Cat")); petService.BuyPet(Gender.Male, DateTime.Now.AddDays(-841), 982, "", breedService.GetIdByName("Chartreux"), categoryService.GetIdByName("Cat")); toyService.BuyFromDistributor("Truck", "", 3.50m, 2, brandService.GetIdByName("Whiskas"), categoryService.GetIdByName("Cat")); toyService.BuyFromDistributor("Car", "", 2.50m, 4, brandService.GetIdByName("9Lives"), categoryService.GetIdByName("Cat")); toyService.BuyFromDistributor("Bear", "", 5.50m, 3, brandService.GetIdByName("Friskies"), categoryService.GetIdByName("Cat")); toyService.BuyFromDistributor("Ball", "", 3.50m, 4, brandService.GetIdByName("Halo"), categoryService.GetIdByName("Cat")); toyService.SellToyToUser(toyService.GetIdByName("Truck"), userService.GetIdByName("Atanas Kolev")); toyService.SellToyToUser(toyService.GetIdByName("Car"), userService.GetIdByName("Atanas Kolev")); toyService.SellToyToUser(toyService.GetIdByName("Bear"), userService.GetIdByName("Daniel Ivanov")); toyService.SellToyToUser(toyService.GetIdByName("Ball"), userService.GetIdByName("Georgi Petrov")); }