├── .gitattributes ├── .gitignore ├── BaseProject ├── BaseProject.csproj ├── Controllers │ ├── AccountController.cs │ └── HomeController.cs ├── Migrations │ ├── 20210518221841_initial.Designer.cs │ ├── 20210518221841_initial.cs │ └── AppIdentityDbContextModelSnapshot.cs ├── Models │ ├── AppIdentityDbContext.cs │ ├── AppUser.cs │ └── ErrorViewModel.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── Views │ ├── Account │ │ └── Login.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── UdemyDesignPatterns.sln ├── WebApp.Adapter ├── Controllers │ ├── AccountController.cs │ └── HomeController.cs ├── Migrations │ ├── 20210518221841_initial.Designer.cs │ ├── 20210518221841_initial.cs │ └── AppIdentityDbContextModelSnapshot.cs ├── Models │ ├── AppIdentityDbContext.cs │ ├── AppUser.cs │ └── ErrorViewModel.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Services │ ├── AdvanceImageProcess.cs │ ├── AdvanceImageProcessAdapter.cs │ ├── IAdvanceImageProcess.cs │ ├── IImageProcess.cs │ └── ImageProcess.cs ├── Startup.cs ├── Views │ ├── Account │ │ └── Login.cshtml │ ├── Home │ │ ├── AddWatermark.cshtml │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WebApp.Adapter.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ ├── lib │ ├── bootstrap │ │ ├── LICENSE │ │ └── dist │ │ │ ├── css │ │ │ ├── bootstrap-grid.css │ │ │ ├── bootstrap-grid.css.map │ │ │ ├── bootstrap-grid.min.css │ │ │ ├── bootstrap-grid.min.css.map │ │ │ ├── bootstrap-reboot.css │ │ │ ├── bootstrap-reboot.css.map │ │ │ ├── bootstrap-reboot.min.css │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ └── js │ │ │ ├── bootstrap.bundle.js │ │ │ ├── bootstrap.bundle.js.map │ │ │ ├── bootstrap.bundle.min.js │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.js.map │ │ │ ├── bootstrap.min.js │ │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ │ ├── LICENSE.txt │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ │ ├── LICENSE.md │ │ └── dist │ │ │ ├── additional-methods.js │ │ │ ├── additional-methods.min.js │ │ │ ├── jquery.validate.js │ │ │ └── jquery.validate.min.js │ └── jquery │ │ ├── LICENSE.txt │ │ └── dist │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ └── jquery.min.map │ └── watermarks │ ├── Wallpaper Colors, splash, 4K, Abstract 8562617301.jpg │ ├── code.png │ └── pexels-kyle-roxas-2138922.jpg ├── WebApp.ChainOfResponsibility ├── ChainOfResponsibility │ ├── ExcelProcessHandler.cs │ ├── IProcessHandler.cs │ ├── Processhandler.cs │ ├── SendEmailProcessHandler.cs │ └── ZipFileProcessHandler.cs ├── Controllers │ ├── AccountController.cs │ └── HomeController.cs ├── Migrations │ ├── 20210518221841_initial.Designer.cs │ ├── 20210518221841_initial.cs │ ├── 20210530004851_AddProductEntity.Designer.cs │ ├── 20210530004851_AddProductEntity.cs │ ├── 20210530004921_AddProductEntity2.Designer.cs │ ├── 20210530004921_AddProductEntity2.cs │ └── AppIdentityDbContextModelSnapshot.cs ├── Models │ ├── AppIdentityDbContext.cs │ ├── AppUser.cs │ ├── ErrorViewModel.cs │ └── Product.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── Views │ ├── Account │ │ └── Login.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WebApp.ChainOfResponsibility.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── WebApp.Command ├── Commands │ ├── CreateExcelTableActionCommand.cs │ ├── CreatePdfTableActionCommand.cs │ ├── EFileType.cs │ ├── ExcelFile.cs │ ├── FileCreateInvoker.cs │ ├── ITableActionCommand.cs │ └── PdfFile.cs ├── Controllers │ ├── AccountController.cs │ ├── HomeController.cs │ └── ProductsController.cs ├── Migrations │ ├── 20210518221841_initial.Designer.cs │ ├── 20210518221841_initial.cs │ ├── 20210527191417_AddProductEntity.Designer.cs │ ├── 20210527191417_AddProductEntity.cs │ ├── 20210527191507_AddProductEntityUpdate.Designer.cs │ ├── 20210527191507_AddProductEntityUpdate.cs │ └── AppIdentityDbContextModelSnapshot.cs ├── Models │ ├── AppIdentityDbContext.cs │ ├── AppUser.cs │ ├── ErrorViewModel.cs │ └── Product.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── Views │ ├── Account │ │ └── Login.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Products │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WebApp.Command.csproj ├── appsettings.Development.json ├── appsettings.json ├── libwkhtmltox.dll └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── WebApp.Composite ├── Composite │ ├── BookComponent.cs │ ├── BookComposite.cs │ └── IComponent.cs ├── Controllers │ ├── AccountController.cs │ ├── CategoryMenuController.cs │ └── HomeController.cs ├── Migrations │ ├── 20210518221841_initial.Designer.cs │ ├── 20210518221841_initial.cs │ ├── 20210530202710_Add_Category_And_Book_Entity.Designer.cs │ ├── 20210530202710_Add_Category_And_Book_Entity.cs │ └── AppIdentityDbContextModelSnapshot.cs ├── Models │ ├── AppIdentityDbContext.cs │ ├── AppUser.cs │ ├── Book.cs │ ├── Category.cs │ └── ErrorViewModel.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── Views │ ├── Account │ │ └── Login.cshtml │ ├── CategoryMenu │ │ └── Index.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WebApp.Composite.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── WebApp.Decorator ├── Controllers │ ├── AccountController.cs │ ├── HomeController.cs │ └── ProductsController.cs ├── Migrations │ ├── 20210518221841_initial.Designer.cs │ ├── 20210518221841_initial.cs │ ├── 20210531231111_Add_ProductEntity.Designer.cs │ ├── 20210531231111_Add_ProductEntity.cs │ └── AppIdentityDbContextModelSnapshot.cs ├── Models │ ├── AppIdentityDbContext.cs │ ├── AppUser.cs │ ├── ErrorViewModel.cs │ └── Product.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Repositories │ ├── Decorator │ │ ├── BaseProductRepositoryDecorator.cs │ │ ├── ProductRepositoryCacheDecorator.cs │ │ └── ProductRepositoryLoggingDecorator.cs │ ├── IProductRepository.cs │ └── ProductRepository.cs ├── Startup.cs ├── Views │ ├── Account │ │ └── Login.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Products │ │ ├── Create.cshtml │ │ ├── Delete.cshtml │ │ ├── Details.cshtml │ │ ├── Edit.cshtml │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WebApp.Decorator.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── WebApp.Observer ├── Controllers │ ├── AccountController.cs │ └── HomeController.cs ├── EventHandlers │ ├── CreateDiscountEventHandler.cs │ ├── CreatedUserWriteConsoleEventHandler.cs │ └── SendEmailEventHandler.cs ├── Events │ └── UserCreatedEvent.cs ├── Migrations │ ├── 20210518221841_initial.Designer.cs │ ├── 20210518221841_initial.cs │ ├── 20210529142308_AddDiscountEntity.Designer.cs │ ├── 20210529142308_AddDiscountEntity.cs │ └── AppIdentityDbContextModelSnapshot.cs ├── Models │ ├── AppIdentityDbContext.cs │ ├── AppUser.cs │ ├── Discount.cs │ ├── ErrorViewModel.cs │ └── UserCreateViewModel.cs ├── Observer │ ├── IUserObserver.cs │ ├── UserObserverCreateDiscount.cs │ ├── UserObserverSendEmail.cs │ ├── UserObserverSubject.cs │ └── UserObserverWriteToConsole.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Startup.cs ├── Views │ ├── Account │ │ ├── Login.cshtml │ │ └── SignUp.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WebApp.Observer.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map ├── WebApp.Strategy ├── Controllers │ ├── AccountController.cs │ ├── HomeController.cs │ ├── ProductsController.cs │ └── SettingsController.cs ├── Migrations │ ├── 20210518221841_initial.Designer.cs │ ├── 20210518221841_initial.cs │ ├── 20210524173407_AddProductEntity.Designer.cs │ ├── 20210524173407_AddProductEntity.cs │ └── AppIdentityDbContextModelSnapshot.cs ├── Models │ ├── AppIdentityDbContext.cs │ ├── AppUser.cs │ ├── EDatabaseType.cs │ ├── ErrorViewModel.cs │ ├── Product.cs │ └── Settings.cs ├── Program.cs ├── Properties │ └── launchSettings.json ├── Repositories │ ├── IProductRepository.cs │ ├── ProductRepositoryFromMongoDb.cs │ └── ProductRepositoryFromSqlServer.cs ├── Startup.cs ├── Views │ ├── Account │ │ └── Login.cshtml │ ├── Home │ │ ├── Index.cshtml │ │ └── Privacy.cshtml │ ├── Products │ │ ├── Create.cshtml │ │ ├── Delete.cshtml │ │ ├── Details.cshtml │ │ ├── Edit.cshtml │ │ └── Index.cshtml │ ├── Settings │ │ └── Index.cshtml │ ├── Shared │ │ ├── Error.cshtml │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml ├── WebApp.Strategy.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ ├── css │ └── site.css │ ├── favicon.ico │ ├── js │ └── site.js │ └── lib │ ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js │ └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map └── WebApp.Template ├── Controllers ├── AccountController.cs └── HomeController.cs ├── Migrations ├── 20210518221841_initial.Designer.cs ├── 20210518221841_initial.cs ├── 20210525220449_AddPropToAppUser.Designer.cs ├── 20210525220449_AddPropToAppUser.cs └── AppIdentityDbContextModelSnapshot.cs ├── Models ├── AppIdentityDbContext.cs ├── AppUser.cs └── ErrorViewModel.cs ├── Program.cs ├── Properties └── launchSettings.json ├── Startup.cs ├── UserCards ├── DefaultUserCardTemplate.cs ├── PrimeUserCardTemplate.cs ├── UserCardTagHelper.cs └── UserCardTemplate.cs ├── Views ├── Account │ └── Login.cshtml ├── Home │ ├── Index.cshtml │ └── Privacy.cshtml ├── Shared │ ├── Error.cshtml │ ├── _Layout.cshtml │ └── _ValidationScriptsPartial.cshtml ├── _ViewImports.cshtml └── _ViewStart.cshtml ├── WebApp.Template.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot ├── css └── site.css ├── favicon.ico ├── js └── site.js ├── lib ├── bootstrap │ ├── LICENSE │ └── dist │ │ ├── css │ │ ├── bootstrap-grid.css │ │ ├── bootstrap-grid.css.map │ │ ├── bootstrap-grid.min.css │ │ ├── bootstrap-grid.min.css.map │ │ ├── bootstrap-reboot.css │ │ ├── bootstrap-reboot.css.map │ │ ├── bootstrap-reboot.min.css │ │ ├── bootstrap-reboot.min.css.map │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ └── js │ │ ├── bootstrap.bundle.js │ │ ├── bootstrap.bundle.js.map │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.js.map │ │ ├── bootstrap.min.js │ │ └── bootstrap.min.js.map ├── jquery-validation-unobtrusive │ ├── LICENSE.txt │ ├── jquery.validate.unobtrusive.js │ └── jquery.validate.unobtrusive.min.js ├── jquery-validation │ ├── LICENSE.md │ └── dist │ │ ├── additional-methods.js │ │ ├── additional-methods.min.js │ │ ├── jquery.validate.js │ │ └── jquery.validate.min.js └── jquery │ ├── LICENSE.txt │ └── dist │ ├── jquery.js │ ├── jquery.min.js │ └── jquery.min.map └── userpictures ├── defaultuserpicture.png └── primeuserpicture.png /BaseProject/BaseProject.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /BaseProject/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaseProject.Controllers 10 | { 11 | public class AccountController : Controller 12 | { 13 | private readonly UserManager _userManager; 14 | private readonly SignInManager _signInManager; 15 | 16 | public AccountController(UserManager userManager, SignInManager signInManager) 17 | { 18 | _userManager = userManager; 19 | _signInManager = signInManager; 20 | } 21 | 22 | public IActionResult Login() 23 | { 24 | return View(); 25 | } 26 | 27 | [HttpPost] 28 | public async Task Login(string email,string password) 29 | { 30 | var hasUser = await _userManager.FindByEmailAsync(email); 31 | 32 | if (hasUser == null) return View(); 33 | 34 | var signInResult = await _signInManager.PasswordSignInAsync(hasUser, password, true, false); 35 | 36 | 37 | 38 | 39 | if(!signInResult.Succeeded) 40 | { 41 | return View(); 42 | } 43 | 44 | return RedirectToAction(nameof(HomeController.Index), "Home"); 45 | 46 | } 47 | public async Task Logout() 48 | { 49 | 50 | 51 | await _signInManager.SignOutAsync(); 52 | 53 | return RedirectToAction(nameof(HomeController.Index), "Home"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /BaseProject/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace BaseProject.Controllers 11 | { 12 | public class HomeController : Controller 13 | { 14 | private readonly ILogger _logger; 15 | 16 | public HomeController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | public IActionResult Index() 22 | { 23 | return View(); 24 | } 25 | 26 | public IActionResult Privacy() 27 | { 28 | return View(); 29 | } 30 | 31 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 32 | public IActionResult Error() 33 | { 34 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BaseProject/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace BaseProject.Models 9 | { 10 | public class AppIdentityDbContext:IdentityDbContext 11 | { 12 | public AppIdentityDbContext(DbContextOptions options) : base(options) 13 | { 14 | 15 | } 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /BaseProject/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser:IdentityUser 10 | { 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /BaseProject/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaseProject.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /BaseProject/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BaseProject/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
7 |
8 | 9 | 10 |
We'll never share your email with anyone else.
11 |
12 |
13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /BaseProject/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome

7 |

Learn about building Web apps with ASP.NET Core.

8 |
9 | -------------------------------------------------------------------------------- /BaseProject/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /BaseProject/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /BaseProject/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /BaseProject/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BaseProject 2 | @using BaseProject.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /BaseProject/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /BaseProject/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /BaseProject/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" 4 | }, 5 | 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /BaseProject/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /BaseProject/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/BaseProject/wwwroot/favicon.ico -------------------------------------------------------------------------------- /BaseProject/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /BaseProject/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /BaseProject/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /BaseProject/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Adapter/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaseProject.Controllers 10 | { 11 | public class AccountController : Controller 12 | { 13 | private readonly UserManager _userManager; 14 | private readonly SignInManager _signInManager; 15 | 16 | public AccountController(UserManager userManager, SignInManager signInManager) 17 | { 18 | _userManager = userManager; 19 | _signInManager = signInManager; 20 | } 21 | 22 | public IActionResult Login() 23 | { 24 | return View(); 25 | } 26 | 27 | [HttpPost] 28 | public async Task Login(string email,string password) 29 | { 30 | var hasUser = await _userManager.FindByEmailAsync(email); 31 | 32 | if (hasUser == null) return View(); 33 | 34 | var signInResult = await _signInManager.PasswordSignInAsync(hasUser, password, true, false); 35 | 36 | 37 | 38 | 39 | if(!signInResult.Succeeded) 40 | { 41 | return View(); 42 | } 43 | 44 | return RedirectToAction(nameof(HomeController.Index), "Home"); 45 | 46 | } 47 | public async Task Logout() 48 | { 49 | 50 | 51 | await _signInManager.SignOutAsync(); 52 | 53 | return RedirectToAction(nameof(HomeController.Index), "Home"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WebApp.Adapter/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace BaseProject.Models 9 | { 10 | public class AppIdentityDbContext:IdentityDbContext 11 | { 12 | public AppIdentityDbContext(DbContextOptions options) : base(options) 13 | { 14 | 15 | } 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WebApp.Adapter/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser:IdentityUser 10 | { 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Adapter/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaseProject.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApp.Adapter/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WebApp.Adapter/Services/AdvanceImageProcess.cs: -------------------------------------------------------------------------------- 1 | using LazZiya.ImageResize; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebApp.Adapter.Services 10 | { 11 | public class AdvanceImageProcess : IAdvanceImageProcess 12 | { 13 | public void AddWatermarkImage(Stream stream, string text, string filePath, Color color, Color outlineColor) 14 | { 15 | using (var img = Image.FromStream(stream)) 16 | { 17 | var tOps = new TextWatermarkOptions 18 | { 19 | // Change text color and opacity 20 | // Text opacity range depends on Color's alpha channel (0 - 255) 21 | TextColor = color, 22 | 23 | // Add text outline 24 | // Outline color opacity range depends on Color's alpha channel (0 - 255) 25 | OutlineColor = outlineColor 26 | }; 27 | 28 | img.AddTextWatermark(text, tOps) 29 | .SaveAs(filePath); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /WebApp.Adapter/Services/AdvanceImageProcessAdapter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebApp.Adapter.Services 9 | { 10 | public class AdvanceImageProcessAdapter : IImageProcess 11 | { 12 | private readonly IAdvanceImageProcess _advanceImageProcess; 13 | 14 | public AdvanceImageProcessAdapter(IAdvanceImageProcess advanceImageProcess) 15 | { 16 | _advanceImageProcess = advanceImageProcess; 17 | } 18 | 19 | public void AddWatermark(string text, string filename, Stream imageStream) 20 | { 21 | _advanceImageProcess.AddWatermarkImage(imageStream, text, $"wwwroot/watermarks/{filename}", Color.FromArgb(128, 255, 255, 255), Color.FromArgb(0, 255, 255, 255)); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /WebApp.Adapter/Services/IAdvanceImageProcess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebApp.Adapter.Services 9 | { 10 | public interface IAdvanceImageProcess 11 | { 12 | // void AddWatermark(string text, string filename, Stream imageStream); 13 | 14 | void AddWatermarkImage(Stream stream, string text, string filePath, Color color, Color outlineColor); 15 | } 16 | } -------------------------------------------------------------------------------- /WebApp.Adapter/Services/IImageProcess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Adapter.Services 8 | { 9 | public interface IImageProcess 10 | { 11 | void AddWatermark(string text, string filename, Stream imageStream); 12 | } 13 | } -------------------------------------------------------------------------------- /WebApp.Adapter/Services/ImageProcess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebApp.Adapter.Services 9 | { 10 | public class ImageProcess : IImageProcess 11 | { 12 | public void AddWatermark(string text, string filename, Stream imageStream) 13 | { 14 | using var img = Image.FromStream(imageStream); 15 | 16 | using var graphic = Graphics.FromImage(img); 17 | 18 | var font = new Font(FontFamily.GenericMonospace, 40, FontStyle.Bold, GraphicsUnit.Pixel); 19 | 20 | var textSize = graphic.MeasureString(text, font); 21 | 22 | var color = Color.FromArgb(128, 255, 255, 255); 23 | var brush = new SolidBrush(color); 24 | 25 | var position = new Point(img.Width - ((int)textSize.Width + 30), img.Height - ((int)textSize.Height + 30)); 26 | 27 | graphic.DrawString(text, font, brush, position); 28 | 29 | img.Save("wwwroot/watermarks/" + filename); 30 | 31 | img.Dispose(); 32 | graphic.Dispose(); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /WebApp.Adapter/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
7 |
8 | 9 | 10 |
We'll never share your email with anyone else.
11 |
12 |
13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /WebApp.Adapter/Views/Home/AddWatermark.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "AddWatermark"; 3 | } 4 |
5 | 6 | 7 | 8 | 9 |
-------------------------------------------------------------------------------- /WebApp.Adapter/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome

7 |

Learn about building Web apps with ASP.NET Core.

8 |
9 | -------------------------------------------------------------------------------- /WebApp.Adapter/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /WebApp.Adapter/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /WebApp.Adapter/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /WebApp.Adapter/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BaseProject 2 | @using BaseProject.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /WebApp.Adapter/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WebApp.Adapter/WebApp.Adapter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /WebApp.Adapter/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApp.Adapter/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" 4 | }, 5 | 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Adapter/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/watermarks/Wallpaper Colors, splash, 4K, Abstract 8562617301.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Adapter/wwwroot/watermarks/Wallpaper Colors, splash, 4K, Abstract 8562617301.jpg -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/watermarks/code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Adapter/wwwroot/watermarks/code.png -------------------------------------------------------------------------------- /WebApp.Adapter/wwwroot/watermarks/pexels-kyle-roxas-2138922.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Adapter/wwwroot/watermarks/pexels-kyle-roxas-2138922.jpg -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/ChainOfResponsibility/ExcelProcessHandler.cs: -------------------------------------------------------------------------------- 1 | using ClosedXML.Excel; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Data; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebApp.ChainOfResponsibility.ChainOfResponsibility 10 | { 11 | public class ExcelProcessHandler : Processhandler 12 | { 13 | private DataTable GetTable(Object o) 14 | { 15 | var table = new DataTable(); 16 | 17 | var type = typeof(T); 18 | 19 | type.GetProperties().ToList().ForEach(x => table.Columns.Add(x.Name, x.PropertyType)); 20 | 21 | var list = o as List; 22 | 23 | list.ForEach(x => 24 | { 25 | var values = type.GetProperties().Select(propertyInfo => propertyInfo.GetValue(x, null)).ToArray(); 26 | 27 | table.Rows.Add(values); 28 | }); 29 | 30 | return table; 31 | } 32 | 33 | public override object handle(object o) 34 | { 35 | var wb = new XLWorkbook(); 36 | var ds = new DataSet(); 37 | 38 | ds.Tables.Add(GetTable(o)); 39 | 40 | wb.Worksheets.Add(ds); 41 | 42 | var excelMemoryStream = new MemoryStream(); 43 | 44 | wb.SaveAs(excelMemoryStream); 45 | 46 | return base.handle(excelMemoryStream); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/ChainOfResponsibility/IProcessHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.ChainOfResponsibility.ChainOfResponsibility 7 | { 8 | public interface IProcessHandler 9 | { 10 | IProcessHandler SetNext(IProcessHandler processHandler); 11 | 12 | Object handle(Object o); 13 | } 14 | } -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/ChainOfResponsibility/Processhandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.ChainOfResponsibility.ChainOfResponsibility 7 | { 8 | public abstract class Processhandler : IProcessHandler 9 | { 10 | private IProcessHandler nextProcessHandler; 11 | 12 | public virtual object handle(object o) 13 | { 14 | if (nextProcessHandler != null) 15 | { 16 | return nextProcessHandler.handle(o); 17 | } 18 | return null; 19 | } 20 | 21 | public IProcessHandler SetNext(IProcessHandler processHandler) 22 | { 23 | nextProcessHandler = processHandler; 24 | return nextProcessHandler; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/ChainOfResponsibility/ZipFileProcessHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.IO.Compression; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebApp.ChainOfResponsibility.ChainOfResponsibility 9 | { 10 | public class ZipFileProcessHandler : Processhandler 11 | { 12 | public override object handle(object o) 13 | { 14 | var excelMemoryStream = o as MemoryStream; 15 | 16 | excelMemoryStream.Position = 0; 17 | 18 | using (var zipStream = new MemoryStream()) 19 | { 20 | using (var archive = new ZipArchive(zipStream, ZipArchiveMode.Create, true)) 21 | { 22 | var zipFile = archive.CreateEntry($"{typeof(T).Name}.xlsx"); 23 | 24 | using (var zipEntry = zipFile.Open()) 25 | { 26 | excelMemoryStream.CopyTo(zipEntry); 27 | } 28 | } 29 | return base.handle(zipStream); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaseProject.Controllers 10 | { 11 | public class AccountController : Controller 12 | { 13 | private readonly UserManager _userManager; 14 | private readonly SignInManager _signInManager; 15 | 16 | public AccountController(UserManager userManager, SignInManager signInManager) 17 | { 18 | _userManager = userManager; 19 | _signInManager = signInManager; 20 | } 21 | 22 | public IActionResult Login() 23 | { 24 | return View(); 25 | } 26 | 27 | [HttpPost] 28 | public async Task Login(string email,string password) 29 | { 30 | var hasUser = await _userManager.FindByEmailAsync(email); 31 | 32 | if (hasUser == null) return View(); 33 | 34 | var signInResult = await _signInManager.PasswordSignInAsync(hasUser, password, true, false); 35 | 36 | 37 | 38 | 39 | if(!signInResult.Succeeded) 40 | { 41 | return View(); 42 | } 43 | 44 | return RedirectToAction(nameof(HomeController.Index), "Home"); 45 | 46 | } 47 | public async Task Logout() 48 | { 49 | 50 | 51 | await _signInManager.SignOutAsync(); 52 | 53 | return RedirectToAction(nameof(HomeController.Index), "Home"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Migrations/20210530004851_AddProductEntity.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace BaseProject.Migrations 4 | { 5 | public partial class AddProductEntity : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | 10 | } 11 | 12 | protected override void Down(MigrationBuilder migrationBuilder) 13 | { 14 | 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Migrations/20210530004921_AddProductEntity2.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace BaseProject.Migrations 4 | { 5 | public partial class AddProductEntity2 : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.CreateTable( 10 | name: "Products", 11 | columns: table => new 12 | { 13 | Id = table.Column(type: "int", nullable: false) 14 | .Annotation("SqlServer:Identity", "1, 1"), 15 | Name = table.Column(type: "nvarchar(max)", nullable: true), 16 | Price = table.Column(type: "decimal(18,2)", nullable: false), 17 | Stock = table.Column(type: "int", nullable: false) 18 | }, 19 | constraints: table => 20 | { 21 | table.PrimaryKey("PK_Products", x => x.Id); 22 | }); 23 | } 24 | 25 | protected override void Down(MigrationBuilder migrationBuilder) 26 | { 27 | migrationBuilder.DropTable( 28 | name: "Products"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using WebApp.ChainOfResponsibility.Models; 8 | 9 | namespace BaseProject.Models 10 | { 11 | public class AppIdentityDbContext : IdentityDbContext 12 | { 13 | public AppIdentityDbContext(DbContextOptions options) : base(options) 14 | { 15 | } 16 | 17 | public DbSet Products { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser:IdentityUser 10 | { 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaseProject.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.ChainOfResponsibility.Models 8 | { 9 | public class Product 10 | { 11 | public int Id { get; set; } 12 | public string Name { get; set; } 13 | 14 | [Column(TypeName = "decimal(18,2)")] 15 | public decimal Price { get; set; } 16 | 17 | public int Stock { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
7 |
8 | 9 | 10 |
We'll never share your email with anyone else.
11 |
12 |
13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 | product tablosunu email olarak gönderir -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BaseProject 2 | @using BaseProject.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/WebApp.ChainOfResponsibility.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" 4 | }, 5 | 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.ChainOfResponsibility/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /WebApp.ChainOfResponsibility/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Command/Commands/CreateExcelTableActionCommand.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Command.Commands 8 | { 9 | public class CreateExcelTableActionCommand : ITableActionCommand 10 | { 11 | private readonly ExcelFile _excelFile; 12 | 13 | public CreateExcelTableActionCommand(ExcelFile excelFile) 14 | { 15 | _excelFile = excelFile; 16 | } 17 | 18 | public IActionResult Execute() 19 | { 20 | var excelMemoryStream = _excelFile.Create(); 21 | 22 | return new FileContentResult(excelMemoryStream.ToArray(), _excelFile.FileType) { FileDownloadName = _excelFile.FileName }; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /WebApp.Command/Commands/CreatePdfTableActionCommand.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Command.Commands 8 | { 9 | public class CreatePdfTableActionCommand : ITableActionCommand 10 | { 11 | private readonly PdfFile _pdfFile; 12 | 13 | public CreatePdfTableActionCommand(PdfFile pdfFile) 14 | { 15 | _pdfFile = pdfFile; 16 | } 17 | 18 | public IActionResult Execute() 19 | { 20 | var excelMemoryStream = _pdfFile.Create(); 21 | 22 | return new FileContentResult(excelMemoryStream.ToArray(), _pdfFile.FileType) { FileDownloadName = _pdfFile.FileName }; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /WebApp.Command/Commands/EFileType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Command.Commands 7 | { 8 | public enum EFileType 9 | { 10 | Excel = 1, 11 | Pdf = 2 12 | } 13 | } -------------------------------------------------------------------------------- /WebApp.Command/Commands/ExcelFile.cs: -------------------------------------------------------------------------------- 1 | using ClosedXML.Excel; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Data; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebApp.Command.Commands 10 | { 11 | public class ExcelFile 12 | { 13 | public readonly List _list; 14 | 15 | public string FileName => $"{typeof(T).Name}.xlsx"; 16 | 17 | public string FileType => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; 18 | 19 | public ExcelFile(List list) 20 | { 21 | _list = list; 22 | } 23 | 24 | public MemoryStream Create() 25 | { 26 | var wb = new XLWorkbook(); 27 | 28 | var ds = new DataSet(); 29 | 30 | ds.Tables.Add(GetTable()); 31 | 32 | wb.Worksheets.Add(ds); 33 | 34 | var excelMemory = new MemoryStream(); 35 | 36 | wb.SaveAs(excelMemory); 37 | return excelMemory; 38 | } 39 | 40 | private DataTable GetTable() 41 | { 42 | var table = new DataTable(); 43 | 44 | var type = typeof(T); 45 | 46 | type.GetProperties().ToList().ForEach(x => table.Columns.Add(x.Name, x.PropertyType)); 47 | 48 | _list.ForEach(x => 49 | { 50 | var values = type.GetProperties().Select(properyInfo => properyInfo.GetValue(x, null)).ToArray(); 51 | 52 | table.Rows.Add(values); 53 | }); 54 | return table; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /WebApp.Command/Commands/FileCreateInvoker.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Command.Commands 8 | { 9 | public class FileCreateInvoker 10 | { 11 | private ITableActionCommand _tableActionCommand; 12 | private List tableActionCommands = new List(); 13 | 14 | public void SetCommand(ITableActionCommand tableActionCommand) 15 | { 16 | _tableActionCommand = tableActionCommand; 17 | } 18 | 19 | public void AddCommand(ITableActionCommand tableActionCommand) 20 | { 21 | tableActionCommands.Add(tableActionCommand); 22 | } 23 | 24 | public IActionResult CreateFile() 25 | { 26 | return _tableActionCommand.Execute(); 27 | } 28 | 29 | public List CreateFiles() 30 | { 31 | return tableActionCommands.Select(x => x.Execute()).ToList(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /WebApp.Command/Commands/ITableActionCommand.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Command.Commands 8 | { 9 | public interface ITableActionCommand 10 | { 11 | IActionResult Execute(); 12 | } 13 | } -------------------------------------------------------------------------------- /WebApp.Command/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaseProject.Controllers 10 | { 11 | public class AccountController : Controller 12 | { 13 | private readonly UserManager _userManager; 14 | private readonly SignInManager _signInManager; 15 | 16 | public AccountController(UserManager userManager, SignInManager signInManager) 17 | { 18 | _userManager = userManager; 19 | _signInManager = signInManager; 20 | } 21 | 22 | public IActionResult Login() 23 | { 24 | return View(); 25 | } 26 | 27 | [HttpPost] 28 | public async Task Login(string email,string password) 29 | { 30 | var hasUser = await _userManager.FindByEmailAsync(email); 31 | 32 | if (hasUser == null) return View(); 33 | 34 | var signInResult = await _signInManager.PasswordSignInAsync(hasUser, password, true, false); 35 | 36 | 37 | 38 | 39 | if(!signInResult.Succeeded) 40 | { 41 | return View(); 42 | } 43 | 44 | return RedirectToAction(nameof(HomeController.Index), "Home"); 45 | 46 | } 47 | public async Task Logout() 48 | { 49 | 50 | 51 | await _signInManager.SignOutAsync(); 52 | 53 | return RedirectToAction(nameof(HomeController.Index), "Home"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WebApp.Command/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | using WebApp.Command.Commands; 10 | using WebApp.Command.Models; 11 | 12 | namespace BaseProject.Controllers 13 | { 14 | public class HomeController : Controller 15 | { 16 | private readonly ILogger _logger; 17 | 18 | public HomeController(ILogger logger) 19 | { 20 | _logger = logger; 21 | } 22 | 23 | public IActionResult Index() 24 | { 25 | return View(); 26 | } 27 | 28 | public IActionResult Privacy() 29 | { 30 | return View(); 31 | } 32 | 33 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 34 | public IActionResult Error() 35 | { 36 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /WebApp.Command/Migrations/20210527191417_AddProductEntity.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace BaseProject.Migrations 4 | { 5 | public partial class AddProductEntity : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | 10 | } 11 | 12 | protected override void Down(MigrationBuilder migrationBuilder) 13 | { 14 | 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WebApp.Command/Migrations/20210527191507_AddProductEntityUpdate.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace BaseProject.Migrations 4 | { 5 | public partial class AddProductEntityUpdate : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.CreateTable( 10 | name: "Products", 11 | columns: table => new 12 | { 13 | Id = table.Column(type: "int", nullable: false) 14 | .Annotation("SqlServer:Identity", "1, 1"), 15 | Name = table.Column(type: "nvarchar(max)", nullable: true), 16 | Price = table.Column(type: "decimal(18,2)", nullable: false), 17 | Stock = table.Column(type: "int", nullable: false) 18 | }, 19 | constraints: table => 20 | { 21 | table.PrimaryKey("PK_Products", x => x.Id); 22 | }); 23 | } 24 | 25 | protected override void Down(MigrationBuilder migrationBuilder) 26 | { 27 | migrationBuilder.DropTable( 28 | name: "Products"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /WebApp.Command/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using WebApp.Command.Models; 8 | 9 | namespace BaseProject.Models 10 | { 11 | public class AppIdentityDbContext : IdentityDbContext 12 | { 13 | public AppIdentityDbContext(DbContextOptions options) : base(options) 14 | { 15 | } 16 | 17 | public DbSet Products { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /WebApp.Command/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser:IdentityUser 10 | { 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Command/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaseProject.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApp.Command/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebApp.Command.Models 9 | { 10 | public class Product 11 | { 12 | [Key] 13 | public int Id { get; set; } 14 | 15 | public string Name { get; set; } 16 | 17 | [Column(TypeName = "decimal(18,2)")] 18 | public decimal Price { get; set; } 19 | 20 | public int Stock { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /WebApp.Command/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WebApp.Command/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
7 |
8 | 9 | 10 |
We'll never share your email with anyone else.
11 |
12 |
13 | 14 | 15 |
16 | 17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /WebApp.Command/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
6 |

Welcome

7 |

Learn about building Web apps with ASP.NET Core.

8 |
9 | -------------------------------------------------------------------------------- /WebApp.Command/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

@ViewData["Title"]

5 | 6 |

Use this page to detail your site's privacy policy.

7 | -------------------------------------------------------------------------------- /WebApp.Command/Views/Products/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "Index"; 5 | } 6 | 7 |

Index

8 | 9 |

10 | Create Excel 11 | 12 | Create Pdf 13 | 14 | Create Excel and Pdf 15 |

16 | 17 | 18 | 19 | 22 | 25 | 28 | 29 | 30 | 31 | @foreach (var item in Model) 32 | { 33 | 34 | 37 | 40 | 43 | 44 | } 45 | 46 |
20 | @Html.DisplayNameFor(model => model.Name) 21 | 23 | @Html.DisplayNameFor(model => model.Price) 24 | 26 | @Html.DisplayNameFor(model => model.Stock) 27 |
35 | @Html.DisplayFor(modelItem => item.Name) 36 | 38 | @Html.DisplayFor(modelItem => item.Price) 39 | 41 | @Html.DisplayFor(modelItem => item.Stock) 42 |
-------------------------------------------------------------------------------- /WebApp.Command/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /WebApp.Command/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /WebApp.Command/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BaseProject 2 | @using BaseProject.Models 3 | @using WebApp.Command.Commands 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /WebApp.Command/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WebApp.Command/WebApp.Command.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | Always 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | all 21 | runtime; build; native; contentfiles; analyzers; buildtransitive 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /WebApp.Command/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApp.Command/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" 4 | }, 5 | 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Command/libwkhtmltox.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Command/libwkhtmltox.dll -------------------------------------------------------------------------------- /WebApp.Command/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /WebApp.Command/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Command/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WebApp.Command/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WebApp.Command/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Command/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /WebApp.Command/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Composite/Composite/BookComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Composite.Composite 7 | { 8 | public class BookComponent : IComponent 9 | { 10 | public int Id { get; set; } 11 | public string Name { get; set; } 12 | 13 | public BookComponent(int id, string name) 14 | { 15 | Id = id; 16 | Name = name; 17 | } 18 | 19 | public int Count() 20 | { 21 | return 1; 22 | } 23 | 24 | public string Display() 25 | { 26 | return $"
  • {Name}
  • "; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /WebApp.Composite/Composite/IComponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Composite.Composite 7 | { 8 | public interface IComponent 9 | { 10 | public int Id { get; set; } 11 | public string Name { get; set; } 12 | 13 | int Count(); 14 | 15 | string Display(); 16 | } 17 | } -------------------------------------------------------------------------------- /WebApp.Composite/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaseProject.Controllers 10 | { 11 | public class AccountController : Controller 12 | { 13 | private readonly UserManager _userManager; 14 | private readonly SignInManager _signInManager; 15 | 16 | public AccountController(UserManager userManager, SignInManager signInManager) 17 | { 18 | _userManager = userManager; 19 | _signInManager = signInManager; 20 | } 21 | 22 | public IActionResult Login() 23 | { 24 | return View(); 25 | } 26 | 27 | [HttpPost] 28 | public async Task Login(string email,string password) 29 | { 30 | var hasUser = await _userManager.FindByEmailAsync(email); 31 | 32 | if (hasUser == null) return View(); 33 | 34 | var signInResult = await _signInManager.PasswordSignInAsync(hasUser, password, true, false); 35 | 36 | 37 | 38 | 39 | if(!signInResult.Succeeded) 40 | { 41 | return View(); 42 | } 43 | 44 | return RedirectToAction(nameof(HomeController.Index), "Home"); 45 | 46 | } 47 | public async Task Logout() 48 | { 49 | 50 | 51 | await _signInManager.SignOutAsync(); 52 | 53 | return RedirectToAction(nameof(HomeController.Index), "Home"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WebApp.Composite/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace BaseProject.Controllers 11 | { 12 | public class HomeController : Controller 13 | { 14 | private readonly ILogger _logger; 15 | 16 | public HomeController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | public IActionResult Index() 22 | { 23 | return View(); 24 | } 25 | 26 | public IActionResult Privacy() 27 | { 28 | return View(); 29 | } 30 | 31 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 32 | public IActionResult Error() 33 | { 34 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /WebApp.Composite/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using WebApp.Composite.Models; 8 | 9 | namespace BaseProject.Models 10 | { 11 | public class AppIdentityDbContext : IdentityDbContext 12 | { 13 | public AppIdentityDbContext(DbContextOptions options) : base(options) 14 | { 15 | } 16 | 17 | public DbSet Categories { get; set; } 18 | public DbSet Books { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /WebApp.Composite/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser:IdentityUser 10 | { 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Composite/Models/Book.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Composite.Models 8 | { 9 | public class Book 10 | { 11 | public int Id { get; set; } 12 | public string Name { get; set; } 13 | 14 | public Category Category { get; set; } 15 | 16 | public int CategoryId { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /WebApp.Composite/Models/Category.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Composite.Models 7 | { 8 | public class Category 9 | { 10 | public int Id { get; set; } 11 | public string Name { get; set; } 12 | 13 | public string UserId { get; set; } 14 | public ICollection Books { get; set; } 15 | 16 | public int ReferenceId { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /WebApp.Composite/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaseProject.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApp.Composite/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WebApp.Composite/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
    7 |
    8 | 9 | 10 |
    We'll never share your email with anyone else.
    11 |
    12 |
    13 | 14 | 15 |
    16 | 17 | 18 |
    19 | 20 | -------------------------------------------------------------------------------- /WebApp.Composite/Views/CategoryMenu/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Index"; 3 | var menu = ViewBag.menu as BookComposite; 4 | } 5 | @section Scripts 6 | { 7 | 22 | 23 | } 24 |
    25 | 26 | 27 | 28 | 29 |
    30 | 31 |
    32 | 33 |
    34 | 35 |
    36 | 37 |
    38 | Toplam kitap(@menu.Count()) 39 |
    40 | 41 |
    42 | 43 | @foreach (var item in menu.Components) 44 | { 45 | @Html.Raw(item.Display()) 46 | } 47 |
    48 |
    49 |
    50 |
    -------------------------------------------------------------------------------- /WebApp.Composite/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
    6 |

    Welcome

    7 |

    Learn about building Web apps with ASP.NET Core.

    8 |
    9 | -------------------------------------------------------------------------------- /WebApp.Composite/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

    @ViewData["Title"]

    5 | 6 |

    Use this page to detail your site's privacy policy.

    7 | -------------------------------------------------------------------------------- /WebApp.Composite/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

    Error.

    7 |

    An error occurred while processing your request.

    8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

    12 | Request ID: @Model.RequestId 13 |

    14 | } 15 | 16 |

    Development Mode

    17 |

    18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

    20 |

    21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

    26 | -------------------------------------------------------------------------------- /WebApp.Composite/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /WebApp.Composite/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BaseProject 2 | @using BaseProject.Models 3 | @using WebApp.Composite.Composite 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /WebApp.Composite/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WebApp.Composite/WebApp.Composite.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /WebApp.Composite/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApp.Composite/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" 4 | }, 5 | 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Composite/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /WebApp.Composite/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Composite/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WebApp.Composite/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WebApp.Composite/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Composite/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /WebApp.Composite/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Decorator/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaseProject.Controllers 10 | { 11 | public class AccountController : Controller 12 | { 13 | private readonly UserManager _userManager; 14 | private readonly SignInManager _signInManager; 15 | 16 | public AccountController(UserManager userManager, SignInManager signInManager) 17 | { 18 | _userManager = userManager; 19 | _signInManager = signInManager; 20 | } 21 | 22 | public IActionResult Login() 23 | { 24 | return View(); 25 | } 26 | 27 | [HttpPost] 28 | public async Task Login(string email,string password) 29 | { 30 | var hasUser = await _userManager.FindByEmailAsync(email); 31 | 32 | if (hasUser == null) return View(); 33 | 34 | var signInResult = await _signInManager.PasswordSignInAsync(hasUser, password, true, false); 35 | 36 | 37 | 38 | 39 | if(!signInResult.Succeeded) 40 | { 41 | return View(); 42 | } 43 | 44 | return RedirectToAction(nameof(HomeController.Index), "Home"); 45 | 46 | } 47 | public async Task Logout() 48 | { 49 | 50 | 51 | await _signInManager.SignOutAsync(); 52 | 53 | return RedirectToAction(nameof(HomeController.Index), "Home"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WebApp.Decorator/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace BaseProject.Controllers 11 | { 12 | public class HomeController : Controller 13 | { 14 | private readonly ILogger _logger; 15 | 16 | public HomeController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | public IActionResult Index() 22 | { 23 | return View(); 24 | } 25 | 26 | public IActionResult Privacy() 27 | { 28 | return View(); 29 | } 30 | 31 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 32 | public IActionResult Error() 33 | { 34 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /WebApp.Decorator/Migrations/20210531231111_Add_ProductEntity.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace BaseProject.Migrations 4 | { 5 | public partial class Add_ProductEntity : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.CreateTable( 10 | name: "Products", 11 | columns: table => new 12 | { 13 | Id = table.Column(type: "int", nullable: false) 14 | .Annotation("SqlServer:Identity", "1, 1"), 15 | Name = table.Column(type: "nvarchar(max)", nullable: true), 16 | Price = table.Column(type: "decimal(18,2)", nullable: false), 17 | Stock = table.Column(type: "int", nullable: false), 18 | UserId = table.Column(type: "nvarchar(max)", nullable: true) 19 | }, 20 | constraints: table => 21 | { 22 | table.PrimaryKey("PK_Products", x => x.Id); 23 | }); 24 | } 25 | 26 | protected override void Down(MigrationBuilder migrationBuilder) 27 | { 28 | migrationBuilder.DropTable( 29 | name: "Products"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WebApp.Decorator/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using WebApp.Decorator.Models; 8 | 9 | namespace BaseProject.Models 10 | { 11 | public class AppIdentityDbContext : IdentityDbContext 12 | { 13 | public AppIdentityDbContext(DbContextOptions options) : base(options) 14 | { 15 | } 16 | 17 | public DbSet Products { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /WebApp.Decorator/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser:IdentityUser 10 | { 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Decorator/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaseProject.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApp.Decorator/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Decorator.Models 8 | { 9 | public class Product 10 | { 11 | public int Id { get; set; } 12 | public string Name { get; set; } 13 | 14 | [Column(TypeName = "decimal(18,2)")] 15 | public decimal Price { get; set; } 16 | 17 | public int Stock { get; set; } 18 | public string UserId { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /WebApp.Decorator/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WebApp.Decorator/Repositories/Decorator/BaseProductRepositoryDecorator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using WebApp.Decorator.Models; 6 | 7 | namespace WebApp.Decorator.Repositories.Decorator 8 | { 9 | public class BaseProductRepositoryDecorator : IProductRepository 10 | { 11 | public readonly IProductRepository _productRepository; 12 | 13 | public BaseProductRepositoryDecorator(IProductRepository productRepository) 14 | { 15 | _productRepository = productRepository; 16 | } 17 | 18 | public virtual async Task> GetAll() 19 | { 20 | return await _productRepository.GetAll(); 21 | } 22 | 23 | public virtual async Task> GetAll(string userId) 24 | { 25 | return await _productRepository.GetAll(userId); 26 | } 27 | 28 | public virtual async Task GetById(int id) 29 | { 30 | return await _productRepository.GetById(id); 31 | } 32 | 33 | public virtual async Task Remove(Product product) 34 | { 35 | await _productRepository.Remove(product); 36 | } 37 | 38 | public virtual async Task Save(Product product) 39 | { 40 | return await _productRepository.Save(product); 41 | } 42 | 43 | public virtual async Task Update(Product product) 44 | { 45 | await _productRepository.Update(product); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /WebApp.Decorator/Repositories/Decorator/ProductRepositoryLoggingDecorator.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using WebApp.Decorator.Models; 7 | 8 | namespace WebApp.Decorator.Repositories.Decorator 9 | { 10 | public class ProductRepositoryLoggingDecorator : BaseProductRepositoryDecorator 11 | { 12 | private readonly ILogger _log; 13 | 14 | public ProductRepositoryLoggingDecorator(IProductRepository productRepository, ILogger log) : base(productRepository) 15 | { 16 | _log = log; 17 | } 18 | 19 | public override Task> GetAll() 20 | { 21 | _log.LogInformation("GetAll methodu çalıştı"); 22 | return base.GetAll(); 23 | } 24 | 25 | public override Task> GetAll(string userId) 26 | { 27 | _log.LogInformation("GetAll(userId) methodu çalıştı"); 28 | return base.GetAll(userId); 29 | } 30 | 31 | public override Task Save(Product product) 32 | { 33 | _log.LogInformation("Save methodu çalıştı"); 34 | return base.Save(product); 35 | } 36 | 37 | public override Task Update(Product product) 38 | { 39 | _log.LogInformation("Update methodu çalıştı"); 40 | return base.Update(product); 41 | } 42 | 43 | public override Task Remove(Product product) 44 | { 45 | _log.LogInformation("Remove methodu çalıştı"); 46 | return base.Remove(product); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /WebApp.Decorator/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using WebApp.Decorator.Models; 6 | 7 | namespace WebApp.Decorator.Repositories 8 | { 9 | public interface IProductRepository 10 | { 11 | Task GetById(int id); 12 | 13 | Task> GetAll(); 14 | 15 | Task> GetAll(string userId); 16 | 17 | Task Save(Product product); 18 | 19 | Task Update(Product product); 20 | 21 | Task Remove(Product product); 22 | } 23 | } -------------------------------------------------------------------------------- /WebApp.Decorator/Repositories/ProductRepository.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using WebApp.Decorator.Models; 8 | 9 | namespace WebApp.Decorator.Repositories 10 | { 11 | public class ProductRepository : IProductRepository 12 | { 13 | private readonly AppIdentityDbContext _context; 14 | 15 | public ProductRepository(AppIdentityDbContext context) 16 | { 17 | _context = context; 18 | } 19 | 20 | public async Task> GetAll() 21 | { 22 | return await _context.Products.ToListAsync(); 23 | } 24 | 25 | public async Task> GetAll(string userId) 26 | { 27 | return await _context.Products.Where(x => x.UserId == userId).ToListAsync(); 28 | } 29 | 30 | public async Task GetById(int id) 31 | { 32 | return await _context.Products.FindAsync(id); 33 | } 34 | 35 | public async Task Remove(Product product) 36 | { 37 | _context.Products.Remove(product); 38 | 39 | await _context.SaveChangesAsync(); 40 | } 41 | 42 | public async Task Save(Product product) 43 | { 44 | await _context.Products.AddAsync(product); 45 | await _context.SaveChangesAsync(); 46 | return product; 47 | } 48 | 49 | public async Task Update(Product product) 50 | { 51 | _context.Products.Update(product); 52 | 53 | await _context.SaveChangesAsync(); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
    7 |
    8 | 9 | 10 |
    We'll never share your email with anyone else.
    11 |
    12 |
    13 | 14 | 15 |
    16 | 17 | 18 |
    19 | 20 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
    6 |

    Welcome

    7 |

    Learn about building Web apps with ASP.NET Core.

    8 |
    9 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

    @ViewData["Title"]

    5 | 6 |

    Use this page to detail your site's privacy policy.

    7 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Products/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model WebApp.Decorator.Models.Product 2 | 3 | @{ 4 | ViewData["Title"] = "Create"; 5 | } 6 | 7 |

    Create

    8 | 9 |

    Product

    10 |
    11 |
    12 |
    13 |
    14 |
    15 |
    16 | 17 | 18 | 19 |
    20 |
    21 | 22 | 23 | 24 |
    25 |
    26 | 27 | 28 | 29 |
    30 | 31 |
    32 | 33 |
    34 |
    35 |
    36 |
    37 | 38 |
    39 | Back to List 40 |
    41 | 42 | @section Scripts { 43 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 44 | } -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Products/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @model WebApp.Decorator.Models.Product 2 | 3 | @{ 4 | ViewData["Title"] = "Delete"; 5 | } 6 | 7 |

    Delete

    8 | 9 |

    Are you sure you want to delete this?

    10 |
    11 |

    Product

    12 |
    13 |
    14 |
    15 | @Html.DisplayNameFor(model => model.Name) 16 |
    17 |
    18 | @Html.DisplayFor(model => model.Name) 19 |
    20 |
    21 | @Html.DisplayNameFor(model => model.Price) 22 |
    23 |
    24 | @Html.DisplayFor(model => model.Price) 25 |
    26 |
    27 | @Html.DisplayNameFor(model => model.Stock) 28 |
    29 |
    30 | @Html.DisplayFor(model => model.Stock) 31 |
    32 |
    33 | @Html.DisplayNameFor(model => model.UserId) 34 |
    35 |
    36 | @Html.DisplayFor(model => model.UserId) 37 |
    38 |
    39 | 40 |
    41 | 42 | | 43 | Back to List 44 |
    45 |
    46 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Products/Details.cshtml: -------------------------------------------------------------------------------- 1 | @model WebApp.Decorator.Models.Product 2 | 3 | @{ 4 | ViewData["Title"] = "Details"; 5 | } 6 | 7 |

    Details

    8 | 9 |
    10 |

    Product

    11 |
    12 |
    13 |
    14 | @Html.DisplayNameFor(model => model.Name) 15 |
    16 |
    17 | @Html.DisplayFor(model => model.Name) 18 |
    19 |
    20 | @Html.DisplayNameFor(model => model.Price) 21 |
    22 |
    23 | @Html.DisplayFor(model => model.Price) 24 |
    25 |
    26 | @Html.DisplayNameFor(model => model.Stock) 27 |
    28 |
    29 | @Html.DisplayFor(model => model.Stock) 30 |
    31 |
    32 | @Html.DisplayNameFor(model => model.UserId) 33 |
    34 |
    35 | @Html.DisplayFor(model => model.UserId) 36 |
    37 |
    38 |
    39 |
    40 | Edit | 41 | Back to List 42 |
    43 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Products/Edit.cshtml: -------------------------------------------------------------------------------- 1 | @model WebApp.Decorator.Models.Product 2 | 3 | @{ 4 | ViewData["Title"] = "Edit"; 5 | } 6 | 7 |

    Edit

    8 | 9 |

    Product

    10 |
    11 |
    12 |
    13 |
    14 |
    15 | 16 | 17 |
    18 | 19 | 20 | 21 |
    22 |
    23 | 24 | 25 | 26 |
    27 |
    28 | 29 | 30 | 31 |
    32 | 33 |
    34 | 35 |
    36 |
    37 |
    38 |
    39 | 40 |
    41 | Back to List 42 |
    43 | 44 | @section Scripts { 45 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 46 | } -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Products/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "Index"; 5 | } 6 | 7 |

    Index

    8 | 9 |

    10 | Create New 11 |

    12 | 13 | 14 | 15 | 18 | 21 | 24 | 27 | 28 | 29 | 30 | 31 | @foreach (var item in Model) { 32 | 33 | 36 | 39 | 42 | 45 | 50 | 51 | } 52 | 53 |
    16 | @Html.DisplayNameFor(model => model.Name) 17 | 19 | @Html.DisplayNameFor(model => model.Price) 20 | 22 | @Html.DisplayNameFor(model => model.Stock) 23 | 25 | @Html.DisplayNameFor(model => model.UserId) 26 |
    34 | @Html.DisplayFor(modelItem => item.Name) 35 | 37 | @Html.DisplayFor(modelItem => item.Price) 38 | 40 | @Html.DisplayFor(modelItem => item.Stock) 41 | 43 | @Html.DisplayFor(modelItem => item.UserId) 44 | 46 | Edit | 47 | Details | 48 | Delete 49 |
    54 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

    Error.

    7 |

    An error occurred while processing your request.

    8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

    12 | Request ID: @Model.RequestId 13 |

    14 | } 15 | 16 |

    Development Mode

    17 |

    18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

    20 |

    21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

    26 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BaseProject 2 | @using BaseProject.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /WebApp.Decorator/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WebApp.Decorator/WebApp.Decorator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /WebApp.Decorator/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApp.Decorator/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" 4 | }, 5 | 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Decorator/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /WebApp.Decorator/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Decorator/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WebApp.Decorator/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WebApp.Decorator/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Decorator/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /WebApp.Decorator/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Observer/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace BaseProject.Controllers 11 | { 12 | public class HomeController : Controller 13 | { 14 | private readonly ILogger _logger; 15 | 16 | public HomeController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | public IActionResult Index() 22 | { 23 | return View(); 24 | } 25 | 26 | public IActionResult Privacy() 27 | { 28 | return View(); 29 | } 30 | 31 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 32 | public IActionResult Error() 33 | { 34 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /WebApp.Observer/EventHandlers/CreateDiscountEventHandler.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using MediatR; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using WebApp.Observer.Events; 10 | 11 | namespace WebApp.Observer.EventHandlers 12 | { 13 | public class CreateDiscountEventHandler : INotificationHandler 14 | { 15 | private readonly AppIdentityDbContext _context; 16 | private readonly ILogger _logger; 17 | 18 | public CreateDiscountEventHandler(AppIdentityDbContext context, ILogger logger) 19 | { 20 | _context = context; 21 | _logger = logger; 22 | } 23 | 24 | public async Task Handle(UserCreatedEvent notification, CancellationToken cancellationToken) 25 | { 26 | await _context.Discounts.AddAsync(new Models.Discount { Rate = 10, UserId = notification.AppUser.Id }); 27 | await _context.SaveChangesAsync(); 28 | _logger.LogInformation("Discount created"); 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /WebApp.Observer/EventHandlers/CreatedUserWriteConsoleEventHandler.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using WebApp.Observer.Events; 9 | 10 | namespace WebApp.Observer.EventHandlers 11 | { 12 | public class CreatedUserWriteConsoleEventHandler : INotificationHandler 13 | { 14 | private readonly ILogger _logger; 15 | 16 | public CreatedUserWriteConsoleEventHandler(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | public Task Handle(UserCreatedEvent notification, CancellationToken cancellationToken) 22 | { 23 | _logger.LogInformation($"user created : Id= {notification.AppUser.Id}"); 24 | 25 | return Task.CompletedTask; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /WebApp.Observer/EventHandlers/SendEmailEventHandler.cs: -------------------------------------------------------------------------------- 1 | using MediatR; 2 | using Microsoft.Extensions.Logging; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Net; 7 | using System.Net.Mail; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | using WebApp.Observer.Events; 11 | 12 | namespace WebApp.Observer.EventHandlers 13 | { 14 | public class SendEmailEventHandler : INotificationHandler 15 | { 16 | private readonly ILogger _logger; 17 | 18 | public SendEmailEventHandler(ILogger logger) 19 | { 20 | _logger = logger; 21 | } 22 | 23 | public Task Handle(UserCreatedEvent notification, CancellationToken cancellationToken) 24 | { 25 | var mailMessage = new MailMessage(); 26 | 27 | var smptClient = new SmtpClient("srvm11.trwww.com"); 28 | 29 | mailMessage.From = new MailAddress("deneme@kariyersistem.com"); 30 | 31 | mailMessage.To.Add(new MailAddress(notification.AppUser.Email)); 32 | 33 | mailMessage.Subject = "Sitemize hoş geldiniz."; 34 | 35 | mailMessage.Body = "

    Sitemizin genel kuralları : bıdı bıdı....

    "; 36 | 37 | mailMessage.IsBodyHtml = true; 38 | smptClient.Port = 587; 39 | smptClient.Credentials = new NetworkCredential("deneme@kariyersistem.com", "Password12*"); 40 | 41 | smptClient.Send(mailMessage); 42 | _logger.LogInformation($"Email was send to user :{notification.AppUser.UserName}"); 43 | 44 | return Task.CompletedTask; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /WebApp.Observer/Events/UserCreatedEvent.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using MediatR; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebApp.Observer.Events 9 | { 10 | public class UserCreatedEvent : INotification 11 | { 12 | public AppUser AppUser { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /WebApp.Observer/Migrations/20210529142308_AddDiscountEntity.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace BaseProject.Migrations 4 | { 5 | public partial class AddDiscountEntity : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.CreateTable( 10 | name: "Discounts", 11 | columns: table => new 12 | { 13 | Id = table.Column(type: "int", nullable: false) 14 | .Annotation("SqlServer:Identity", "1, 1"), 15 | UserId = table.Column(type: "nvarchar(max)", nullable: true), 16 | Rate = table.Column(type: "int", nullable: false) 17 | }, 18 | constraints: table => 19 | { 20 | table.PrimaryKey("PK_Discounts", x => x.Id); 21 | }); 22 | } 23 | 24 | protected override void Down(MigrationBuilder migrationBuilder) 25 | { 26 | migrationBuilder.DropTable( 27 | name: "Discounts"); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /WebApp.Observer/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using WebApp.Observer.Models; 8 | 9 | namespace BaseProject.Models 10 | { 11 | public class AppIdentityDbContext : IdentityDbContext 12 | { 13 | public AppIdentityDbContext(DbContextOptions options) : base(options) 14 | { 15 | } 16 | 17 | public DbSet Discounts { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /WebApp.Observer/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser:IdentityUser 10 | { 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Observer/Models/Discount.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Observer.Models 7 | { 8 | public class Discount 9 | { 10 | public int Id { get; set; } 11 | public string UserId { get; set; } 12 | public int Rate { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /WebApp.Observer/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaseProject.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApp.Observer/Models/UserCreateViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Observer.Models 7 | { 8 | public class UserCreateViewModel 9 | { 10 | public string UserName { get; set; } 11 | public string Email { get; set; } 12 | public string Password { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /WebApp.Observer/Observer/IUserObserver.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Observer.Observer 8 | { 9 | public interface IUserObserver 10 | { 11 | void UserCreated(AppUser appUser); 12 | } 13 | } -------------------------------------------------------------------------------- /WebApp.Observer/Observer/UserObserverCreateDiscount.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebApp.Observer.Observer 10 | { 11 | public class UserObserverCreateDiscount : IUserObserver 12 | { 13 | private readonly IServiceProvider _serviceProvider; 14 | 15 | public UserObserverCreateDiscount(IServiceProvider serviceProvider) 16 | { 17 | _serviceProvider = serviceProvider; 18 | } 19 | 20 | public void UserCreated(AppUser appUser) 21 | { 22 | var logger = _serviceProvider.GetRequiredService>(); 23 | 24 | using var scope = _serviceProvider.CreateScope(); 25 | 26 | var context = scope.ServiceProvider.GetRequiredService(); 27 | 28 | context.Discounts.Add(new Models.Discount { Rate = 10, UserId = appUser.Id }); 29 | context.SaveChanges(); 30 | logger.LogInformation("Discount created"); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /WebApp.Observer/Observer/UserObserverSendEmail.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Net; 8 | using System.Net.Mail; 9 | using System.Threading.Tasks; 10 | 11 | namespace WebApp.Observer.Observer 12 | { 13 | public class UserObserverSendEmail : IUserObserver 14 | { 15 | private readonly IServiceProvider _serviceProvider; 16 | 17 | public UserObserverSendEmail(IServiceProvider serviceProvider) 18 | { 19 | _serviceProvider = serviceProvider; 20 | } 21 | 22 | public void UserCreated(AppUser appUser) 23 | { 24 | var logger = _serviceProvider.GetRequiredService>(); 25 | 26 | var mailMessage = new MailMessage(); 27 | 28 | var smptClient = new SmtpClient("srvm11.trwww.com"); 29 | 30 | mailMessage.From = new MailAddress("deneme@kariyersistem.com"); 31 | 32 | mailMessage.To.Add(new MailAddress(appUser.Email)); 33 | 34 | mailMessage.Subject = "Sitemize hoş geldiniz."; 35 | 36 | mailMessage.Body = "

    Sitemizin genel kuralları : bıdı bıdı....

    "; 37 | 38 | mailMessage.IsBodyHtml = true; 39 | smptClient.Port = 587; 40 | smptClient.Credentials = new NetworkCredential("deneme@kariyersistem.com", "Password12*"); 41 | 42 | smptClient.Send(mailMessage); 43 | logger.LogInformation($"Email was send to user :{appUser.UserName}"); 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /WebApp.Observer/Observer/UserObserverSubject.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Observer.Observer 8 | { 9 | public class UserObserverSubject 10 | { 11 | private readonly List _userObservers; 12 | 13 | public UserObserverSubject() 14 | { 15 | _userObservers = new List(); 16 | } 17 | 18 | public void RegisterObserver(IUserObserver userObserver) 19 | { 20 | _userObservers.Add(userObserver); 21 | } 22 | 23 | public void RemoveObserver(IUserObserver userObserver) 24 | { 25 | _userObservers.Remove(userObserver); 26 | } 27 | 28 | public void NotifyObservers(AppUser appUser) 29 | { 30 | _userObservers.ForEach(x => 31 | { 32 | x.UserCreated(appUser); 33 | }); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /WebApp.Observer/Observer/UserObserverWriteToConsole.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebApp.Observer.Observer 10 | { 11 | public class UserObserverWriteToConsole : IUserObserver 12 | { 13 | private readonly IServiceProvider _serviceProvider; 14 | 15 | public UserObserverWriteToConsole(IServiceProvider serviceProvider) 16 | { 17 | _serviceProvider = serviceProvider; 18 | } 19 | 20 | public void UserCreated(AppUser appUser) 21 | { 22 | var logger = _serviceProvider.GetRequiredService>(); 23 | 24 | logger.LogInformation($"user created : Id= {appUser.Id}"); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /WebApp.Observer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WebApp.Observer/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
    7 |
    8 | 9 | 10 |
    We'll never share your email with anyone else.
    11 |
    12 |
    13 | 14 | 15 |
    16 | 17 | 18 |
    19 | 20 | -------------------------------------------------------------------------------- /WebApp.Observer/Views/Account/SignUp.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "SignUp"; 3 | } 4 | @model UserCreateViewModel 5 |

    SignUp

    6 |

    @ViewBag.message

    7 |
    8 | 9 |
    10 | 11 | 12 |
    13 | 14 |
    15 | 16 | 17 |
    We'll never share your email with anyone else.
    18 |
    19 |
    20 | 21 | 22 |
    23 | 24 | 25 |
    -------------------------------------------------------------------------------- /WebApp.Observer/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
    6 |

    Welcome

    7 |

    Learn about building Web apps with ASP.NET Core.

    8 |
    9 | -------------------------------------------------------------------------------- /WebApp.Observer/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

    @ViewData["Title"]

    5 | 6 |

    Use this page to detail your site's privacy policy.

    7 | -------------------------------------------------------------------------------- /WebApp.Observer/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

    Error.

    7 |

    An error occurred while processing your request.

    8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

    12 | Request ID: @Model.RequestId 13 |

    14 | } 15 | 16 |

    Development Mode

    17 |

    18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

    20 |

    21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

    26 | -------------------------------------------------------------------------------- /WebApp.Observer/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /WebApp.Observer/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BaseProject 2 | @using BaseProject.Models 3 | @using WebApp.Observer.Models 4 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /WebApp.Observer/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WebApp.Observer/WebApp.Observer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | all 14 | runtime; build; native; contentfiles; analyzers; buildtransitive 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /WebApp.Observer/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApp.Observer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" 4 | }, 5 | 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Observer/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /WebApp.Observer/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Observer/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WebApp.Observer/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WebApp.Observer/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Observer/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /WebApp.Observer/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Strategy/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaseProject.Controllers 10 | { 11 | public class AccountController : Controller 12 | { 13 | private readonly UserManager _userManager; 14 | private readonly SignInManager _signInManager; 15 | 16 | public AccountController(UserManager userManager, SignInManager signInManager) 17 | { 18 | _userManager = userManager; 19 | _signInManager = signInManager; 20 | } 21 | 22 | public IActionResult Login() 23 | { 24 | return View(); 25 | } 26 | 27 | [HttpPost] 28 | public async Task Login(string email,string password) 29 | { 30 | var hasUser = await _userManager.FindByEmailAsync(email); 31 | 32 | if (hasUser == null) return View(); 33 | 34 | var signInResult = await _signInManager.PasswordSignInAsync(hasUser, password, true, false); 35 | 36 | 37 | 38 | 39 | if(!signInResult.Succeeded) 40 | { 41 | return View(); 42 | } 43 | 44 | return RedirectToAction(nameof(HomeController.Index), "Home"); 45 | 46 | } 47 | public async Task Logout() 48 | { 49 | 50 | 51 | await _signInManager.SignOutAsync(); 52 | 53 | return RedirectToAction(nameof(HomeController.Index), "Home"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WebApp.Strategy/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.Extensions.Logging; 3 | using System.Diagnostics; 4 | using WebApp.Strategy.Models; 5 | 6 | namespace BaseProject.Controllers 7 | { 8 | public class HomeController : Controller 9 | { 10 | private readonly ILogger _logger; 11 | 12 | public HomeController(ILogger logger) 13 | { 14 | _logger = logger; 15 | } 16 | 17 | public IActionResult Index() 18 | { 19 | return View(); 20 | } 21 | 22 | public IActionResult Privacy() 23 | { 24 | return View(); 25 | } 26 | 27 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 28 | public IActionResult Error() 29 | { 30 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /WebApp.Strategy/Migrations/20210524173407_AddProductEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace BaseProject.Migrations 5 | { 6 | public partial class AddProductEntity : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.CreateTable( 11 | name: "Products", 12 | columns: table => new 13 | { 14 | Id = table.Column(type: "nvarchar(450)", nullable: false), 15 | Name = table.Column(type: "nvarchar(max)", nullable: true), 16 | Price = table.Column(type: "decimal(18,2)", nullable: false), 17 | Stock = table.Column(type: "int", nullable: false), 18 | UserId = table.Column(type: "nvarchar(max)", nullable: true), 19 | CreatedDate = table.Column(type: "datetime2", nullable: false) 20 | }, 21 | constraints: table => 22 | { 23 | table.PrimaryKey("PK_Products", x => x.Id); 24 | }); 25 | } 26 | 27 | protected override void Down(MigrationBuilder migrationBuilder) 28 | { 29 | migrationBuilder.DropTable( 30 | name: "Products"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /WebApp.Strategy/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 3 | using Microsoft.EntityFrameworkCore; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using WebApp.Strategy.Models; 9 | 10 | namespace BaseProject.Models 11 | { 12 | public class AppIdentityDbContext:IdentityDbContext 13 | { 14 | public AppIdentityDbContext(DbContextOptions options) : base(options) 15 | { 16 | 17 | } 18 | 19 | 20 | public DbSet Products { get; set; } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /WebApp.Strategy/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser:IdentityUser 10 | { 11 | 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Strategy/Models/EDatabaseType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Strategy.Models 7 | { 8 | public enum EDatabaseType 9 | { 10 | SqlServer=1, 11 | MongoDb=2 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WebApp.Strategy/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace WebApp.Strategy.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApp.Strategy/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using MongoDB.Bson; 2 | using MongoDB.Bson.Serialization.Attributes; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel.DataAnnotations; 6 | using System.ComponentModel.DataAnnotations.Schema; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace WebApp.Strategy.Models 11 | { 12 | public class Product 13 | { 14 | 15 | [BsonId] 16 | [Key] 17 | [BsonRepresentation(BsonType.ObjectId)] 18 | public string Id { get; set; } 19 | public string Name { get; set; } 20 | 21 | [BsonRepresentation(BsonType.Decimal128)] 22 | [Column(TypeName ="decimal(18,2)")] 23 | public decimal Price { get; set; } 24 | public int Stock { get; set; } 25 | 26 | public string UserId { get; set; } 27 | [BsonRepresentation(BsonType.DateTime)] 28 | public DateTime CreatedDate { get; set; } 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WebApp.Strategy/Models/Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Strategy.Models 7 | { 8 | public class Settings 9 | { 10 | public static string claimDatabaseType = "databasetype"; 11 | 12 | public EDatabaseType DatabaseType; 13 | 14 | public EDatabaseType GetDefaultDatabaseType => EDatabaseType.SqlServer; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WebApp.Strategy/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WebApp.Strategy/Repositories/IProductRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using WebApp.Strategy.Models; 6 | 7 | namespace WebApp.Strategy.Repositories 8 | { 9 | public interface IProductRepository 10 | { 11 | 12 | Task GetById(string id); 13 | 14 | Task> GetAllByUserId(string userId); 15 | 16 | Task Save(Product product); 17 | Task Update(Product product); 18 | Task Delete(Product product); 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
    7 |
    8 | 9 | 10 |
    We'll never share your email with anyone else.
    11 |
    12 |
    13 | 14 | 15 |
    16 | 17 | 18 |
    19 | 20 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | } 4 | 5 |
    6 |

    Welcome

    7 |

    Learn about building Web apps with ASP.NET Core.

    8 |
    9 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

    @ViewData["Title"]

    5 | 6 |

    Use this page to detail your site's privacy policy.

    7 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Products/Create.cshtml: -------------------------------------------------------------------------------- 1 | @model WebApp.Strategy.Models.Product 2 | 3 | @{ 4 | ViewData["Title"] = "Create"; 5 | } 6 | 7 |

    Create

    8 | 9 |

    Product

    10 |
    11 |
    12 |
    13 |
    14 |
    15 | 16 |
    17 | 18 | 19 | 20 |
    21 |
    22 | 23 | 24 | 25 |
    26 |
    27 | 28 | 29 | 30 |
    31 | 32 | 33 |
    34 | 35 |
    36 |
    37 |
    38 |
    39 | 40 |
    41 | Back to List 42 |
    43 | 44 | @section Scripts { 45 | @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} 46 | } 47 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Products/Delete.cshtml: -------------------------------------------------------------------------------- 1 | @model WebApp.Strategy.Models.Product 2 | 3 | @{ 4 | ViewData["Title"] = "Delete"; 5 | } 6 | 7 |

    Delete

    8 | 9 |

    Are you sure you want to delete this?

    10 |
    11 |

    Product

    12 |
    13 |
    14 |
    15 | @Html.DisplayNameFor(model => model.Name) 16 |
    17 |
    18 | @Html.DisplayFor(model => model.Name) 19 |
    20 |
    21 | @Html.DisplayNameFor(model => model.Price) 22 |
    23 |
    24 | @Html.DisplayFor(model => model.Price) 25 |
    26 |
    27 | @Html.DisplayNameFor(model => model.Stock) 28 |
    29 |
    30 | @Html.DisplayFor(model => model.Stock) 31 |
    32 |
    33 | @Html.DisplayNameFor(model => model.UserId) 34 |
    35 |
    36 | @Html.DisplayFor(model => model.UserId) 37 |
    38 |
    39 | @Html.DisplayNameFor(model => model.CreatedDate) 40 |
    41 |
    42 | @Html.DisplayFor(model => model.CreatedDate) 43 |
    44 |
    45 | 46 |
    47 | 48 | | 49 | Back to List 50 |
    51 |
    52 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Products/Details.cshtml: -------------------------------------------------------------------------------- 1 | @model WebApp.Strategy.Models.Product 2 | 3 | @{ 4 | ViewData["Title"] = "Details"; 5 | } 6 | 7 |

    Details

    8 | 9 |
    10 |

    Product

    11 |
    12 |
    13 |
    14 | @Html.DisplayNameFor(model => model.Name) 15 |
    16 |
    17 | @Html.DisplayFor(model => model.Name) 18 |
    19 |
    20 | @Html.DisplayNameFor(model => model.Price) 21 |
    22 |
    23 | @Html.DisplayFor(model => model.Price) 24 |
    25 |
    26 | @Html.DisplayNameFor(model => model.Stock) 27 |
    28 |
    29 | @Html.DisplayFor(model => model.Stock) 30 |
    31 |
    32 | @Html.DisplayNameFor(model => model.UserId) 33 |
    34 |
    35 | @Html.DisplayFor(model => model.UserId) 36 |
    37 |
    38 | @Html.DisplayNameFor(model => model.CreatedDate) 39 |
    40 |
    41 | @Html.DisplayFor(model => model.CreatedDate) 42 |
    43 |
    44 |
    45 |
    46 | Edit | 47 | Back to List 48 |
    49 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Settings/Index.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Index"; 4 | } 5 | @model Settings 6 | 7 |
    8 | 9 | 10 | 11 | 12 |
    13 | 14 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

    Error.

    7 |

    An error occurred while processing your request.

    8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

    12 | Request ID: @Model.RequestId 13 |

    14 | } 15 | 16 |

    Development Mode

    17 |

    18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

    20 |

    21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

    26 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using WebApp.Strategy 2 | @using WebApp.Strategy.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /WebApp.Strategy/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WebApp.Strategy/WebApp.Strategy.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /WebApp.Strategy/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApp.Strategy/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False", 4 | "MongoDb": "mongodb+srv://fcakiroglu16:Password12@cluster0.onvrv.mongodb.net/myFirstDatabase?retryWrites=true&w=majority" 5 | }, 6 | 7 | "Logging": { 8 | "LogLevel": { 9 | "Default": "Information", 10 | "Microsoft": "Warning", 11 | "Microsoft.Hosting.Lifetime": "Information" 12 | } 13 | }, 14 | "AllowedHosts": "*" 15 | } 16 | -------------------------------------------------------------------------------- /WebApp.Strategy/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /WebApp.Strategy/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Strategy/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WebApp.Strategy/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WebApp.Strategy/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Strategy/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /WebApp.Strategy/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Template/Controllers/AccountController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace BaseProject.Controllers 10 | { 11 | public class AccountController : Controller 12 | { 13 | private readonly UserManager _userManager; 14 | private readonly SignInManager _signInManager; 15 | 16 | public AccountController(UserManager userManager, SignInManager signInManager) 17 | { 18 | _userManager = userManager; 19 | _signInManager = signInManager; 20 | } 21 | 22 | public IActionResult Login() 23 | { 24 | return View(); 25 | } 26 | 27 | [HttpPost] 28 | public async Task Login(string email,string password) 29 | { 30 | var hasUser = await _userManager.FindByEmailAsync(email); 31 | 32 | if (hasUser == null) return View(); 33 | 34 | var signInResult = await _signInManager.PasswordSignInAsync(hasUser, password, true, false); 35 | 36 | 37 | 38 | 39 | if(!signInResult.Succeeded) 40 | { 41 | return View(); 42 | } 43 | 44 | return RedirectToAction(nameof(HomeController.Index), "Home"); 45 | 46 | } 47 | public async Task Logout() 48 | { 49 | 50 | 51 | await _signInManager.SignOutAsync(); 52 | 53 | return RedirectToAction(nameof(HomeController.Index), "Home"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /WebApp.Template/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Identity; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.Extensions.Logging; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.Diagnostics; 9 | using System.Linq; 10 | using System.Threading.Tasks; 11 | 12 | namespace BaseProject.Controllers 13 | { 14 | public class HomeController : Controller 15 | { 16 | private readonly ILogger _logger; 17 | private readonly UserManager _userManager; 18 | 19 | public HomeController(ILogger logger, UserManager userManager) 20 | { 21 | _logger = logger; 22 | _userManager = userManager; 23 | } 24 | 25 | public async Task Index() 26 | { 27 | return View(await _userManager.Users.ToListAsync()); 28 | } 29 | 30 | public IActionResult Privacy() 31 | { 32 | return View(); 33 | } 34 | 35 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 36 | public IActionResult Error() 37 | { 38 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /WebApp.Template/Migrations/20210525220449_AddPropToAppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace BaseProject.Migrations 4 | { 5 | public partial class AddPropToAppUser : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.AddColumn( 10 | name: "Description", 11 | table: "AspNetUsers", 12 | type: "nvarchar(max)", 13 | nullable: true); 14 | 15 | migrationBuilder.AddColumn( 16 | name: "PictureUrl", 17 | table: "AspNetUsers", 18 | type: "nvarchar(max)", 19 | nullable: true); 20 | } 21 | 22 | protected override void Down(MigrationBuilder migrationBuilder) 23 | { 24 | migrationBuilder.DropColumn( 25 | name: "Description", 26 | table: "AspNetUsers"); 27 | 28 | migrationBuilder.DropColumn( 29 | name: "PictureUrl", 30 | table: "AspNetUsers"); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /WebApp.Template/Models/AppIdentityDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore; 2 | using Microsoft.EntityFrameworkCore; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | 8 | namespace BaseProject.Models 9 | { 10 | public class AppIdentityDbContext:IdentityDbContext 11 | { 12 | public AppIdentityDbContext(DbContextOptions options) : base(options) 13 | { 14 | 15 | } 16 | 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WebApp.Template/Models/AppUser.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Identity; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace BaseProject.Models 8 | { 9 | public class AppUser : IdentityUser 10 | { 11 | public string PictureUrl { get; set; } 12 | public string Description { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /WebApp.Template/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace BaseProject.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WebApp.Template/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64605", 7 | "sslPort": 44397 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": false, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "BaseProject": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /WebApp.Template/UserCards/DefaultUserCardTemplate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace WebApp.Template.UserCards 7 | { 8 | public class DefaultUserCardTemplate : UserCardTemplate 9 | { 10 | protected override string SetFooter() 11 | { 12 | return string.Empty; 13 | } 14 | 15 | protected override string SetPicture() 16 | { 17 | return $""; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /WebApp.Template/UserCards/PrimeUserCardTemplate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace WebApp.Template.UserCards 8 | { 9 | public class PrimeUserCardTemplate : UserCardTemplate 10 | { 11 | protected override string SetFooter() 12 | { 13 | var sb = new StringBuilder(); 14 | 15 | sb.Append("Mesaj gönder"); 16 | sb.Append("Detaylı profil"); 17 | return sb.ToString(); 18 | } 19 | 20 | protected override string SetPicture() 21 | { 22 | return $""; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /WebApp.Template/UserCards/UserCardTagHelper.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Razor.TagHelpers; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | 9 | namespace WebApp.Template.UserCards 10 | { 11 | public class UserCardTagHelper : TagHelper 12 | { 13 | public AppUser AppUser { get; set; } 14 | 15 | private readonly IHttpContextAccessor _httpContextAccessor; 16 | 17 | public UserCardTagHelper(IHttpContextAccessor httpContextAccessor) 18 | { 19 | _httpContextAccessor = httpContextAccessor; 20 | } 21 | 22 | public override void Process(TagHelperContext context, TagHelperOutput output) 23 | { 24 | UserCardTemplate userCardTemplate; 25 | 26 | if (_httpContextAccessor.HttpContext.User.Identity.IsAuthenticated) 27 | { 28 | userCardTemplate = new PrimeUserCardTemplate(); 29 | } 30 | else 31 | { 32 | userCardTemplate = new DefaultUserCardTemplate(); 33 | } 34 | 35 | userCardTemplate.SetUser(AppUser); 36 | 37 | output.Content.SetHtmlContent(userCardTemplate.Build()); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /WebApp.Template/UserCards/UserCardTemplate.cs: -------------------------------------------------------------------------------- 1 | using BaseProject.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace WebApp.Template.UserCards 9 | { 10 | public abstract class UserCardTemplate 11 | { 12 | protected AppUser AppUser { get; set; } 13 | 14 | public void SetUser(AppUser appUser) 15 | { 16 | AppUser = appUser; 17 | } 18 | 19 | public string Build() 20 | { 21 | if (AppUser == null) throw new ArgumentNullException(nameof(AppUser)); 22 | 23 | var sb = new StringBuilder(); 24 | 25 | sb.Append("
    "); 26 | sb.Append(SetPicture()); 27 | sb.Append($@"
    28 |
    {AppUser.UserName}
    29 |

    {AppUser.Description}

    "); 30 | sb.Append(SetFooter()); 31 | sb.Append("
    "); 32 | sb.Append("
    "); 33 | 34 | return sb.ToString(); 35 | } 36 | 37 | protected abstract string SetFooter(); 38 | 39 | protected abstract string SetPicture(); 40 | } 41 | } -------------------------------------------------------------------------------- /WebApp.Template/Views/Account/Login.cshtml: -------------------------------------------------------------------------------- 1 |  2 | @{ 3 | ViewData["Title"] = "Login"; 4 | } 5 | 6 |
    7 |
    8 | 9 | 10 |
    We'll never share your email with anyone else.
    11 |
    12 |
    13 | 14 | 15 |
    16 | 17 | 18 |
    19 | 20 | -------------------------------------------------------------------------------- /WebApp.Template/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | int count = 0; 4 | } 5 | @model List 6 | 7 | @foreach (var item in Model) 8 | { 9 | 10 | count++; 11 | if (count == 1 || count % 5 == 1) 12 | { 13 | 14 | @Html.Raw("
    ") 15 | } 16 | 17 |
    18 | 19 |
    20 | 21 | if (count % 5 == 0) 22 | { 23 | @Html.Raw("
    ") 24 | } 25 | } -------------------------------------------------------------------------------- /WebApp.Template/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | } 4 |

    @ViewData["Title"]

    5 | 6 |

    Use this page to detail your site's privacy policy.

    7 | -------------------------------------------------------------------------------- /WebApp.Template/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

    Error.

    7 |

    An error occurred while processing your request.

    8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

    12 | Request ID: @Model.RequestId 13 |

    14 | } 15 | 16 |

    Development Mode

    17 |

    18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

    20 |

    21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

    26 | -------------------------------------------------------------------------------- /WebApp.Template/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /WebApp.Template/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using BaseProject 2 | @using BaseProject.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @addTagHelper *, WebApp.Template -------------------------------------------------------------------------------- /WebApp.Template/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /WebApp.Template/WebApp.Template.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | all 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /WebApp.Template/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WebApp.Template/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "SqlServer": "Data Source=EXCALIBUR\\SQLEXPRESS;Initial Catalog=UdemyDesignPatternDb;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False" 4 | }, 5 | 6 | "Logging": { 7 | "LogLevel": { 8 | "Default": "Information", 9 | "Microsoft": "Warning", 10 | "Microsoft.Hosting.Lifetime": "Information" 11 | } 12 | }, 13 | "AllowedHosts": "*" 14 | } 15 | -------------------------------------------------------------------------------- /WebApp.Template/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | /* Provide sufficient contrast against white background */ 11 | a { 12 | color: #0366d6; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 22 | color: #fff; 23 | background-color: #1b6ec2; 24 | border-color: #1861ac; 25 | } 26 | 27 | /* Sticky footer styles 28 | -------------------------------------------------- */ 29 | html { 30 | font-size: 14px; 31 | } 32 | @media (min-width: 768px) { 33 | html { 34 | font-size: 16px; 35 | } 36 | } 37 | 38 | .border-top { 39 | border-top: 1px solid #e5e5e5; 40 | } 41 | .border-bottom { 42 | border-bottom: 1px solid #e5e5e5; 43 | } 44 | 45 | .box-shadow { 46 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 47 | } 48 | 49 | button.accept-policy { 50 | font-size: 1rem; 51 | line-height: inherit; 52 | } 53 | 54 | /* Sticky footer styles 55 | -------------------------------------------------- */ 56 | html { 57 | position: relative; 58 | min-height: 100%; 59 | } 60 | 61 | body { 62 | /* Margin bottom by footer height */ 63 | margin-bottom: 60px; 64 | } 65 | .footer { 66 | position: absolute; 67 | bottom: 0; 68 | width: 100%; 69 | white-space: nowrap; 70 | line-height: 60px; /* Vertically center the text there */ 71 | } 72 | -------------------------------------------------------------------------------- /WebApp.Template/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Template/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WebApp.Template/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /WebApp.Template/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2018 Twitter, Inc. 4 | Copyright (c) 2011-2018 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Template/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /WebApp.Template/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WebApp.Template/wwwroot/userpictures/defaultuserpicture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Template/wwwroot/userpictures/defaultuserpicture.png -------------------------------------------------------------------------------- /WebApp.Template/wwwroot/userpictures/primeuserpicture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fcakiroglu16/UdemyDesignPatterns/1d8a19dca0262248a9a60d93d2853ad5ad3a26f9/WebApp.Template/wwwroot/userpictures/primeuserpicture.png --------------------------------------------------------------------------------