Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            FakeDB.InitData();
            services.AddScoped <IPetService, PetService>();
            services.AddScoped <IPetRepository, PetRepository>();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the static data from the fake database(pet objects),
        /// calls the method for showing the primary menu, and another method for the selection of the primary menu
        /// </summary>
        public void StartUI()
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.Clear();

            FakeDB.InitData();

            var selection = ShowMenu();

            HandleSelection(selection);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            FakeDB.InitData();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var petService      = serviceProvider.GetRequiredService <IPetService>();

            new Printer(petService);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            FakeDB.InitData();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetShopRepository, PetshopRepository>();
            serviceCollection.AddScoped <IPetShopService, PetShopService>();
            serviceCollection.AddScoped <IPrinter, Printer>();

            var serviceProvider = serviceCollection.BuildServiceProvider();

            var printer = serviceProvider.GetRequiredService <IPrinter>();

            printer.StartUI();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <ICandlesRepository, CandlesRepository>();
            serviceCollection.AddScoped <ICandlesService, CandlesService>();


            serviceCollection.AddScoped <IPrinter, Printer>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var printer         = serviceProvider.GetRequiredService <IPrinter>();

            FakeDB.InitData();
            printer.MakeMenu();
        }
        static void Main(string[] args)
        {
            FakeDB.InitData();

            ServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IOwnerRepository, OwnerRepository>();

            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
            IPetService     petService      = serviceProvider.GetRequiredService <IPetService>();

            Menu menu = new Menu(petService);

            menu.Run();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            FakeDB.InitData();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IOwnerRepository, OwnerRepository>();
            serviceCollection.AddScoped <IOwnerService, OwnerService>();
            serviceCollection.AddScoped <IValidateIdService, ValidationService>();
            serviceCollection.AddScoped <IPrinter, Printer>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var petPrinter      = serviceProvider.GetRequiredService <IPrinter>();

            petPrinter.ChooseMenu();
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            NewConsole nc = new NewConsole();

            FakeDB.InitData();
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IOwnerRepository, OwnerRepository>();
            serviceCollection.AddScoped <IOwnerService, OwnerService>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var petService      = serviceProvider.GetRequiredService <IPetService>();
            var ownerService    = serviceProvider.GetRequiredService <IOwnerService>();

            new MainMenu(petService, ownerService);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IPrinter, Printer>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var printer         = serviceProvider.GetRequiredService <IPrinter>();

            FakeDB.InitData();
            printer.StartUi();

            //IPetRepository petRepository = new PetRepository();
            //IPetService petService = new PetService(petRepository);
            //var printer = new Printer(petService);
        }
Exemplo n.º 10
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                FakeDB.InitData();
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IPrinter, Printer>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var petService      = serviceProvider.GetRequiredService <IPetService>();
            var fakeDB          = new FakeDB(petService);

            fakeDB.InitData();

            var printer = serviceProvider.GetRequiredService <IPrinter>();

            printer.StartUI();

            Console.ReadLine();
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            IPetRepository petRepository = new PetRepository();

            IPetTypeRepository petTypeRepository = new PetTypeRepository();

            IOwnerRepository ownerRepository = new OwnerRepository();

            IPetService petService = new PetService(petRepository, ownerRepository, petTypeRepository);

            IOwnerService ownerService = new OwnerService(ownerRepository, petRepository);

            FakeDB.InitData();



            Printer print = new Printer(petService, ownerService);

            print.PrintMenu();
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            FakeDB.InitData();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var petService      = serviceProvider.GetRequiredService <IPetService>();

            while (true)
            {
                Console.Clear();
                new Printer(petService);
                Console.WriteLine("\nHit enter to return to the main menu.", Console.ForegroundColor = ConsoleColor.DarkRed);
                Console.ReadLine();
            }
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            FakeDB.InitData();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <ICarRepository, CarRepository>();
            serviceCollection.AddScoped <ICarService, CarService>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var carService      = serviceProvider.GetRequiredService <ICarService>();

            new Printer(carService);

            Console.ReadLine();

            /*////then build provider
             * var serviceProvider = serviceCollection.BuildServiceProvider();
             * var printer = serviceProvider.GetRequiredService<IPrinter>();
             * printer.StartUI();*/
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            ConsoleMenu menu = new ConsoleMenu();

            menu.Run();

            FakeDB.InitData();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IConsoleMenu, ConsoleMenu>();
            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var petService      = serviceProvider.GetRequiredService <IPetService>();

            //new Printer(petService);

            Console.ReadLine();
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            // create initial data
            FakeDB.InitData();

            // using ms dependency injection package
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IPetRepository, PetRepository>();
            serviceCollection.AddScoped <IPetService, PetService>();
            serviceCollection.AddScoped <IPrinter, Printer>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var printer         = serviceProvider.GetRequiredService <IPrinter>();

            printer.ShowMenu();

            // To be removed:
            // By using serviceCollection, does this mean that the
            // repo dependency injection in the pet service also can be removed?
            //
            //IPetRepository petRepository = new PetRepository();
            //IPetService service = new PetService(petRepository);
        }
Exemplo n.º 17
0
 public static void Main(string[] args)
 {
     FakeDB.InitData();
     CreateWebHostBuilder(args).Build().Run();
 }
Exemplo n.º 18
0
 public Startup(IConfiguration configuration)
 {
     Configuration = configuration;
     FakeDB.InitData();
 }
Exemplo n.º 19
0
 public PetsRepository()
 {
     FakeDB.InitData();
 }
Exemplo n.º 20
0
 public void InitialiseData()
 {
     _pets = FakeDB.InitData();
     IDAfterInit();
 }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            FakeDB.InitData();
            IPetRepository PR = new PetRepository();
            IPetService    PS = new PetService(PR);

            do
            {
                Console.WriteLine("Welcome to my little Pet shop");
                Console.WriteLine("0. Exit");
                Console.WriteLine("1. Show all pets");
                Console.WriteLine("2. Search pets");
                Console.WriteLine("3. Create new pet");
                Console.WriteLine("4. Delete pet");
                Console.WriteLine("5. Update pet");
                Console.WriteLine("6. Sort pets by Price");
                Console.WriteLine("7. Show 5 cheapest pets");
                switch (Int32.Parse(Console.ReadLine()))
                {
                case 0:
                    Run = false;
                    break;

                case 1:
                    foreach (var Pet in PS.GetPets())
                    {
                        Console.WriteLine(Pet.ToString());
                    }
                    break;

                case 2:
                    foreach (var Pet in PS.GetPetsByType(Console.ReadLine()))
                    {
                        Console.WriteLine(Pet.ToString());
                    }
                    break;

                case 3:
                    PS.CreatePet();
                    break;

                case 4:
                    PS.DeletePet();
                    break;

                case 5:
                    Console.WriteLine("Please enter ID of a pet you want to update");
                    PS.UpdatePet(int.Parse(Console.ReadLine()));
                    Console.WriteLine("Dont write anything if you dont want to update selected information");
                    break;

                case 6:
                    PS.SortPetsByPrice();
                    break;

                case 7:
                    foreach (var Pet in PS.GetFiveCheapest())
                    {
                        Console.WriteLine(Pet.ToString());
                    }
                    break;

                default:
                    break;
                }
            } while (Run);
        }
Exemplo n.º 22
0
 static void Main(string[] args)
 {
     FakeDB.InitData();
     var printer = new Printer(new PetService(new PetRepository()));
 }
Exemplo n.º 23
0
 public IEnumerable <Pet> ReadAll()
 {
     return(FakeDB.InitData());
 }