Example #1
0
        static void Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddScoped <IAvatarRepository, AvatarRepo>();
            serviceCollection.AddScoped <IAvatarService, AvatarService>();
            serviceCollection.AddScoped <IPrinter, Printer>();

            var serviceProvider = serviceCollection.BuildServiceProvider();
            var avatarRepo      = serviceProvider.GetRequiredService <IAvatarRepository>();
            var Printer         = serviceProvider.GetRequiredService <IPrinter>();

            new DBInitializer(avatarRepo).InitData;



            IAvatarRepository aRepo = new AvatarRepo();

            DBInitializer db = new DBInitializer(aRepo);

            db.InitData(); // Mock data
            IAvatarService aService = new AvatarService(aRepo);
            IPrinter       print    = new Printer(aService);

            Console.WriteLine("Hello fellow Seven Deadly Sins maniac!");

            Console.WriteLine("Welcome to SDS\nBegin your adventure by choosing an option in the menu");
            print.StartUI();
        }
Example #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseSwagger();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            using (var scope = app.ApplicationServices.CreateScope())
            {
                var repo  = scope.ServiceProvider.GetRequiredService <IAvatarRepository>();
                var orepo = scope.ServiceProvider.GetRequiredService <IOwnerRepository>();
                var trepo = scope.ServiceProvider.GetRequiredService <ITypeRepository>();

                /* repo.Create(new Avatar { Name = "Chili", AvatarType = "Magician", Color = "Pink" });
                 * repo.Create(new Avatar { Name = "Bunsy", AvatarType = "Healer", Color = "Black" });*/

                IAvatarRepository aRepo  = new AvatarRepo();
                IOwnerRepository  owRepo = new OwnerRepo();
                ITypeRepository   tyrepo = new TypeRepo();


                DBInit.InitData(); // Mock data
                IAvatarService aService  = new AvatarService(aRepo);
                IOwnerService  owService = new OwnerService(owRepo);
                ITypeService   tService  = new TypeService(tyrepo);



                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                    // c.RoutePrefix = string.Empty;
                });

                app.UseHttpsRedirection();
                app.UseRouting();

                app.UseCors("CustomerAppAllowSpecificOrigins");


                app.UseAuthorization();

                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                });
            }
        }
Example #3
0
        public Header()
        {
            InitializeComponent();

            if (this.NotInDesignMode())
            {
                _apiSettings = DIService.GetSingleton<ApiSettings>();
                _sessionInfoRepo = DIService.GetSingleton<SessionInfoRepo>();
                _userInfoRepo = DIService.GetSingleton<UserInfoRepo>();
                _avatarRepo = DIService.GetSingleton<AvatarRepo>();
                _dialogMessagesRepo = DIService.GetSingleton<DialogMessagesRepo>();

                UpdateHeaderInfo();
            }
        }
Example #4
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();
            }

            //This is new

            using (var scope = app.ApplicationServices.CreateScope())
            {
                var repo   = scope.ServiceProvider.GetRequiredService <IAvatarRepository>();
                var atrepo = scope.ServiceProvider.GetRequiredService <IAvatarTypeRepository>();
                var owrepo = scope.ServiceProvider.GetRequiredService <IOwnerRepository>();
                //repo.Create(new Avatar { Name = "Bunsy", Type ="Bunny", Color ="Blue"});
                //repo.Create(new Avatar { Name = "Chili", Type = "Magician", Color = "Pink" });

                IAvatarRepository     avatarRepository     = new AvatarRepo();
                IAvatarTypeRepository avatarTypeRepository = new AvatarTypeRepo();
                IOwnerRepository      ownerRepository      = new OwnerRepo();

                //new DBinitializer  = new DBinitializer();
                //d.InitData();

                DBinitializer.InitData();
                IAvatarService     avatarService     = new AvatarService(avatarRepository);
                IAvatarTypeService avatarTypeService = new AvatarTypeService(avatarTypeRepository);
                IOwnerService      ownerService      = new OwnerService(ownerRepository);



                //YOU DID GITHUB WIHT TERMINAL !!!


                // app.UseWelcomePage();

                app.UseHttpsRedirection();

                app.UseRouting();

                app.UseAuthorization();

                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                });
            }
        }
Example #5
0
 public AvatarService()
 {
     _avatarRepo = DIService.GetSingleton<AvatarRepo>();
     _userInfoRepo = DIService.GetSingleton<UserInfoRepo>();
 }
Example #6
0
        static void Main(string[] args)
        {
            /* avatarRepository = new AvatarRepo();
             * {
             *   var avatar1 = new Avatar
             *   {
             *       Id = id++,
             *       Name = "Bradley",
             *       Type = "Meliodas",
             *       Birthday = DateTime.Now.Date,
             *       SoldDate = DateTime.Now.Date,
             *       Color = "blue",
             *       PreviousOwner = "Lotte",
             *       Price = 2
             *   };
             *   avatarList.Add(avatar1);
             *   //Console.WriteLine($"Name: {avatar1.Username}");
             *   avatarList.Add(new Avatar()
             *   {
             *       Id = id++,
             *       Name = "Chili",
             *       Type = "Chililove",
             *       Birthday = DateTime.Now.Date,
             *       SoldDate = DateTime.Now.Date,
             *       Color = "purple",
             *       PreviousOwner = "hans",
             *       Price = 1
             *   });
             *
             *   //avatarRepository.Create(avatar1);
             *
             *
             * };*/
            IAvatarRepository aRepo    = new AvatarRepo();
            IAvatarService    aService = new AvatarService(aRepo);
            Printer           print    = new Printer(aService);

            Console.WriteLine("Hello fellow Seven Deadly Sins maniac!");

            Console.WriteLine("Welcome to SDS\nBegin your adventure by choosing an option in the menu");

            var selection = ShowMenu();

            while (selection != 5)
            {
                switch (selection)
                {
                case 1:
                    print.CreateAvatar();
                    break;

                case 2:
                    ListAvatars();
                    break;

                case 3:
                    print.UpdateAvatar();
                    break;

                case 4:
                    print.Delete();
                    break;

                default:
                    break;
                }

                Console.WriteLine("Try again sinner");
                Console.ReadLine();
                ClearMenu();



                selection = ShowMenu();
            }
            Console.WriteLine("See you soon");
            Console.ReadLine();
            ClearMenu();
        }