├── src ├── 02 │ ├── Completed │ │ ├── MyShop.Web │ │ │ ├── Views │ │ │ │ ├── _ViewStart.cshtml │ │ │ │ ├── _ViewImports.cshtml │ │ │ │ ├── Customer │ │ │ │ │ └── Index.cshtml │ │ │ │ ├── Shared │ │ │ │ │ ├── Error.cshtml │ │ │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ │ │ └── _CookieConsentPartial.cshtml │ │ │ │ └── Order │ │ │ │ │ └── Index.cshtml │ │ │ ├── orders.db │ │ │ ├── appsettings.json │ │ │ ├── wwwroot │ │ │ │ ├── favicon.ico │ │ │ │ ├── js │ │ │ │ │ └── site.js │ │ │ │ ├── lib │ │ │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ │ │ └── LICENSE.txt │ │ │ │ │ ├── jquery-validation │ │ │ │ │ │ └── LICENSE.md │ │ │ │ │ ├── bootstrap │ │ │ │ │ │ └── LICENSE │ │ │ │ │ └── jquery │ │ │ │ │ │ └── LICENSE.txt │ │ │ │ └── css │ │ │ │ │ └── site.css │ │ │ ├── appsettings.Development.json │ │ │ ├── Models │ │ │ │ ├── LineItemModel.cs │ │ │ │ ├── ErrorViewModel.cs │ │ │ │ ├── CreateOrderModel.cs │ │ │ │ └── CustomerModel.cs │ │ │ ├── MyShop.Web.csproj │ │ │ ├── Program.cs │ │ │ └── Controllers │ │ │ │ ├── CustomerController.cs │ │ │ │ └── OrderController.cs │ │ ├── .vs │ │ │ └── MyShop │ │ │ │ ├── v16 │ │ │ │ ├── .suo │ │ │ │ └── TestStore │ │ │ │ │ └── 0 │ │ │ │ │ ├── 000.testlog │ │ │ │ │ └── testlog.manifest │ │ │ │ └── DesignTimeBuild │ │ │ │ └── .dtbcache.v2 │ │ ├── MyShop.Domain │ │ │ ├── MyShop.Domain.csproj │ │ │ └── Models │ │ │ │ ├── Product.cs │ │ │ │ ├── Customer.cs │ │ │ │ ├── LineItem.cs │ │ │ │ └── Order.cs │ │ ├── MyShop.Infrastructure │ │ │ ├── Repositories │ │ │ │ ├── IRepository.cs │ │ │ │ ├── ProductRepository.cs │ │ │ │ ├── CustomerRepository.cs │ │ │ │ ├── OrderRepository.cs │ │ │ │ └── GenericRepository.cs │ │ │ ├── MyShop.Infrastructure.csproj │ │ │ └── ShoppingContext.cs │ │ └── MyShop.Web.Tests │ │ │ ├── MyShop.Web.Tests.csproj │ │ │ └── OrderControllerTests.cs │ └── Start_Here │ │ ├── MyShop.Web │ │ ├── Views │ │ │ ├── _ViewStart.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ ├── Customer │ │ │ │ └── Index.cshtml │ │ │ ├── Shared │ │ │ │ ├── Error.cshtml │ │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ │ └── _CookieConsentPartial.cshtml │ │ │ └── Order │ │ │ │ └── Index.cshtml │ │ ├── orders.db │ │ ├── wwwroot │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ │ └── site.js │ │ │ ├── lib │ │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ │ └── LICENSE.txt │ │ │ │ ├── jquery-validation │ │ │ │ │ └── LICENSE.md │ │ │ │ ├── bootstrap │ │ │ │ │ └── LICENSE │ │ │ │ └── jquery │ │ │ │ │ └── LICENSE.txt │ │ │ └── css │ │ │ │ └── site.css │ │ ├── appsettings.Development.json │ │ ├── appsettings.json │ │ ├── Models │ │ │ ├── LineItemModel.cs │ │ │ ├── ErrorViewModel.cs │ │ │ ├── CreateOrderModel.cs │ │ │ └── CustomerModel.cs │ │ ├── MyShop.Web.csproj │ │ ├── Controllers │ │ │ ├── CustomerController.cs │ │ │ └── OrderController.cs │ │ ├── Program.cs │ │ └── Startup.cs │ │ ├── MyShop.Domain │ │ ├── MyShop.Domain.csproj │ │ └── Models │ │ │ ├── Product.cs │ │ │ ├── Customer.cs │ │ │ ├── LineItem.cs │ │ │ └── Order.cs │ │ ├── MyShop.Infrastructure │ │ ├── MyShop.Infrastructure.csproj │ │ └── ShoppingContext.cs │ │ └── MyShop.sln ├── 03 │ ├── Completed │ │ ├── MyShop.Web │ │ │ ├── Views │ │ │ │ ├── _ViewStart.cshtml │ │ │ │ ├── _ViewImports.cshtml │ │ │ │ ├── Customer │ │ │ │ │ └── Index.cshtml │ │ │ │ ├── Shared │ │ │ │ │ ├── Error.cshtml │ │ │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ │ │ └── _CookieConsentPartial.cshtml │ │ │ │ └── Order │ │ │ │ │ └── Index.cshtml │ │ │ ├── orders.db │ │ │ ├── appsettings.json │ │ │ ├── wwwroot │ │ │ │ ├── favicon.ico │ │ │ │ ├── js │ │ │ │ │ └── site.js │ │ │ │ ├── lib │ │ │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ │ │ └── LICENSE.txt │ │ │ │ │ ├── jquery-validation │ │ │ │ │ │ └── LICENSE.md │ │ │ │ │ ├── bootstrap │ │ │ │ │ │ └── LICENSE │ │ │ │ │ └── jquery │ │ │ │ │ │ └── LICENSE.txt │ │ │ │ └── css │ │ │ │ │ └── site.css │ │ │ ├── appsettings.Development.json │ │ │ ├── Models │ │ │ │ ├── LineItemModel.cs │ │ │ │ ├── ErrorViewModel.cs │ │ │ │ ├── CreateOrderModel.cs │ │ │ │ └── CustomerModel.cs │ │ │ ├── MyShop.Web.csproj │ │ │ ├── Program.cs │ │ │ └── Controllers │ │ │ │ └── CustomerController.cs │ │ ├── .vs │ │ │ └── MyShop │ │ │ │ ├── v16 │ │ │ │ ├── .suo │ │ │ │ └── TestStore │ │ │ │ │ └── 0 │ │ │ │ │ ├── 000.testlog │ │ │ │ │ └── testlog.manifest │ │ │ │ └── DesignTimeBuild │ │ │ │ └── .dtbcache.v2 │ │ ├── MyShop.Domain │ │ │ ├── MyShop.Domain.csproj │ │ │ └── Models │ │ │ │ ├── Product.cs │ │ │ │ ├── Customer.cs │ │ │ │ ├── LineItem.cs │ │ │ │ └── Order.cs │ │ ├── MyShop.Infrastructure │ │ │ ├── Repositories │ │ │ │ ├── IRepository.cs │ │ │ │ ├── ProductRepository.cs │ │ │ │ ├── CustomerRepository.cs │ │ │ │ ├── OrderRepository.cs │ │ │ │ └── GenericRepository.cs │ │ │ ├── MyShop.Infrastructure.csproj │ │ │ ├── ShoppingContext.cs │ │ │ └── UnitOfWork.cs │ │ └── MyShop.Web.Tests │ │ │ ├── MyShop.Web.Tests.csproj │ │ │ └── OrderControllerTests.cs │ └── Start_Here │ │ ├── MyShop.Web │ │ ├── Views │ │ │ ├── _ViewStart.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ ├── Customer │ │ │ │ └── Index.cshtml │ │ │ ├── Shared │ │ │ │ ├── Error.cshtml │ │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ │ └── _CookieConsentPartial.cshtml │ │ │ └── Order │ │ │ │ └── Index.cshtml │ │ ├── orders.db │ │ ├── appsettings.json │ │ ├── wwwroot │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ │ └── site.js │ │ │ ├── lib │ │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ │ └── LICENSE.txt │ │ │ │ ├── jquery-validation │ │ │ │ │ └── LICENSE.md │ │ │ │ ├── bootstrap │ │ │ │ │ └── LICENSE │ │ │ │ └── jquery │ │ │ │ │ └── LICENSE.txt │ │ │ └── css │ │ │ │ └── site.css │ │ ├── appsettings.Development.json │ │ ├── Models │ │ │ ├── LineItemModel.cs │ │ │ ├── ErrorViewModel.cs │ │ │ ├── CreateOrderModel.cs │ │ │ └── CustomerModel.cs │ │ ├── MyShop.Web.csproj │ │ ├── Program.cs │ │ └── Controllers │ │ │ └── CustomerController.cs │ │ ├── .vs │ │ └── MyShop │ │ │ ├── v16 │ │ │ ├── .suo │ │ │ └── TestStore │ │ │ │ └── 0 │ │ │ │ ├── 000.testlog │ │ │ │ └── testlog.manifest │ │ │ └── DesignTimeBuild │ │ │ └── .dtbcache.v2 │ │ ├── MyShop.Domain │ │ ├── MyShop.Domain.csproj │ │ └── Models │ │ │ ├── Product.cs │ │ │ ├── Customer.cs │ │ │ ├── LineItem.cs │ │ │ └── Order.cs │ │ ├── MyShop.Infrastructure │ │ ├── Repositories │ │ │ ├── IRepository.cs │ │ │ ├── ProductRepository.cs │ │ │ ├── CustomerRepository.cs │ │ │ ├── OrderRepository.cs │ │ │ └── GenericRepository.cs │ │ ├── MyShop.Infrastructure.csproj │ │ └── ShoppingContext.cs │ │ └── MyShop.Web.Tests │ │ ├── MyShop.Web.Tests.csproj │ │ └── OrderControllerTests.cs └── 04 │ ├── Completed │ ├── MyShop.Web │ │ ├── Views │ │ │ ├── _ViewStart.cshtml │ │ │ ├── _ViewImports.cshtml │ │ │ ├── Shared │ │ │ │ ├── Error.cshtml │ │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ │ └── _CookieConsentPartial.cshtml │ │ │ ├── Customer │ │ │ │ └── Index.cshtml │ │ │ └── Order │ │ │ │ └── Index.cshtml │ │ ├── orders.db │ │ ├── appsettings.json │ │ ├── wwwroot │ │ │ ├── favicon.ico │ │ │ ├── js │ │ │ │ └── site.js │ │ │ ├── lib │ │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ │ └── LICENSE.txt │ │ │ │ ├── jquery-validation │ │ │ │ │ └── LICENSE.md │ │ │ │ ├── bootstrap │ │ │ │ │ └── LICENSE │ │ │ │ └── jquery │ │ │ │ │ └── LICENSE.txt │ │ │ └── css │ │ │ │ └── site.css │ │ ├── appsettings.Development.json │ │ ├── Models │ │ │ ├── LineItemModel.cs │ │ │ ├── ErrorViewModel.cs │ │ │ ├── CreateOrderModel.cs │ │ │ └── CustomerModel.cs │ │ ├── MyShop.Web.csproj │ │ ├── Program.cs │ │ └── Controllers │ │ │ └── CustomerController.cs │ ├── .vs │ │ └── MyShop │ │ │ ├── v16 │ │ │ ├── .suo │ │ │ └── TestStore │ │ │ │ └── 0 │ │ │ │ ├── 000.testlog │ │ │ │ └── testlog.manifest │ │ │ └── DesignTimeBuild │ │ │ └── .dtbcache.v2 │ ├── MyShop.Domain │ │ ├── MyShop.Domain.csproj │ │ ├── Models │ │ │ ├── Product.cs │ │ │ ├── LineItem.cs │ │ │ ├── Customer.cs │ │ │ └── Order.cs │ │ └── Lazy │ │ │ └── ValueHolder.cs │ ├── MyShop.Infrastructure │ │ ├── Repositories │ │ │ ├── IRepository.cs │ │ │ ├── ProductRepository.cs │ │ │ ├── OrderRepository.cs │ │ │ ├── GenericRepository.cs │ │ │ └── CustomerRepository.cs │ │ ├── MyShop.Infrastructure.csproj │ │ ├── Lazy │ │ │ └── Proxies │ │ │ │ └── CustomerProxy.cs │ │ ├── ShoppingContext.cs │ │ └── UnitOfWork.cs │ └── MyShop.Web.Tests │ │ ├── MyShop.Web.Tests.csproj │ │ └── OrderControllerTests.cs │ └── Start_Here │ ├── MyShop.Web │ ├── Views │ │ ├── _ViewStart.cshtml │ │ ├── _ViewImports.cshtml │ │ ├── Customer │ │ │ └── Index.cshtml │ │ ├── Shared │ │ │ ├── Error.cshtml │ │ │ ├── _ValidationScriptsPartial.cshtml │ │ │ └── _CookieConsentPartial.cshtml │ │ └── Order │ │ │ └── Index.cshtml │ ├── orders.db │ ├── appsettings.json │ ├── wwwroot │ │ ├── favicon.ico │ │ ├── js │ │ │ └── site.js │ │ ├── lib │ │ │ ├── jquery-validation-unobtrusive │ │ │ │ └── LICENSE.txt │ │ │ ├── jquery-validation │ │ │ │ └── LICENSE.md │ │ │ ├── bootstrap │ │ │ │ └── LICENSE │ │ │ └── jquery │ │ │ │ └── LICENSE.txt │ │ └── css │ │ │ └── site.css │ ├── appsettings.Development.json │ ├── Models │ │ ├── LineItemModel.cs │ │ ├── ErrorViewModel.cs │ │ ├── CreateOrderModel.cs │ │ └── CustomerModel.cs │ ├── MyShop.Web.csproj │ ├── Program.cs │ └── Controllers │ │ └── CustomerController.cs │ ├── .vs │ └── MyShop │ │ ├── v16 │ │ ├── .suo │ │ └── TestStore │ │ │ └── 0 │ │ │ ├── 000.testlog │ │ │ └── testlog.manifest │ │ └── DesignTimeBuild │ │ └── .dtbcache.v2 │ ├── MyShop.Domain │ ├── MyShop.Domain.csproj │ └── Models │ │ ├── Product.cs │ │ ├── Customer.cs │ │ ├── LineItem.cs │ │ └── Order.cs │ ├── MyShop.Infrastructure │ ├── Repositories │ │ ├── IRepository.cs │ │ ├── ProductRepository.cs │ │ ├── CustomerRepository.cs │ │ ├── OrderRepository.cs │ │ └── GenericRepository.cs │ ├── MyShop.Infrastructure.csproj │ ├── ShoppingContext.cs │ └── UnitOfWork.cs │ └── MyShop.Web.Tests │ ├── MyShop.Web.Tests.csproj │ └── OrderControllerTests.cs └── LICENSE /src/02/Completed/MyShop.Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /src/02/Completed/.vs/MyShop/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/02/Completed/.vs/MyShop/v16/.suo -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MyShop.Web 2 | @using MyShop.Web.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/orders.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/02/Completed/MyShop.Web/orders.db -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MyShop.Web 2 | @using MyShop.Web.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/03/Completed/.vs/MyShop/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Completed/.vs/MyShop/v16/.suo -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MyShop.Web 2 | @using MyShop.Web.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/orders.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Completed/MyShop.Web/orders.db -------------------------------------------------------------------------------- /src/03/Start_Here/.vs/MyShop/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Start_Here/.vs/MyShop/v16/.suo -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MyShop.Web 2 | @using MyShop.Web.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/04/Completed/.vs/MyShop/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Completed/.vs/MyShop/v16/.suo -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MyShop.Web 2 | @using MyShop.Web.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/orders.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Completed/MyShop.Web/orders.db -------------------------------------------------------------------------------- /src/04/Start_Here/.vs/MyShop/v16/.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Start_Here/.vs/MyShop/v16/.suo -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using MyShop.Web 2 | @using MyShop.Web.Models 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/orders.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/02/Start_Here/MyShop.Web/orders.db -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/orders.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Start_Here/MyShop.Web/orders.db -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/orders.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Start_Here/MyShop.Web/orders.db -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Warning" 5 | } 6 | }, 7 | "AllowedHosts": "*" 8 | } 9 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/02/Completed/MyShop.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Completed/MyShop.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Completed/MyShop.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/02/Start_Here/MyShop.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Start_Here/MyShop.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Start_Here/MyShop.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/02/Completed/.vs/MyShop/v16/TestStore/0/000.testlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/02/Completed/.vs/MyShop/v16/TestStore/0/000.testlog -------------------------------------------------------------------------------- /src/03/Completed/.vs/MyShop/v16/TestStore/0/000.testlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Completed/.vs/MyShop/v16/TestStore/0/000.testlog -------------------------------------------------------------------------------- /src/04/Completed/.vs/MyShop/v16/TestStore/0/000.testlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Completed/.vs/MyShop/v16/TestStore/0/000.testlog -------------------------------------------------------------------------------- /src/02/Completed/.vs/MyShop/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/02/Completed/.vs/MyShop/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /src/03/Completed/.vs/MyShop/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Completed/.vs/MyShop/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /src/03/Start_Here/.vs/MyShop/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Start_Here/.vs/MyShop/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /src/03/Start_Here/.vs/MyShop/v16/TestStore/0/000.testlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Start_Here/.vs/MyShop/v16/TestStore/0/000.testlog -------------------------------------------------------------------------------- /src/04/Completed/.vs/MyShop/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Completed/.vs/MyShop/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /src/04/Start_Here/.vs/MyShop/DesignTimeBuild/.dtbcache.v2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Start_Here/.vs/MyShop/DesignTimeBuild/.dtbcache.v2 -------------------------------------------------------------------------------- /src/04/Start_Here/.vs/MyShop/v16/TestStore/0/000.testlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Start_Here/.vs/MyShop/v16/TestStore/0/000.testlog -------------------------------------------------------------------------------- /src/02/Completed/.vs/MyShop/v16/TestStore/0/testlog.manifest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/02/Completed/.vs/MyShop/v16/TestStore/0/testlog.manifest -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/03/Completed/.vs/MyShop/v16/TestStore/0/testlog.manifest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Completed/.vs/MyShop/v16/TestStore/0/testlog.manifest -------------------------------------------------------------------------------- /src/04/Completed/.vs/MyShop/v16/TestStore/0/testlog.manifest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Completed/.vs/MyShop/v16/TestStore/0/testlog.manifest -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Domain/MyShop.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/03/Start_Here/.vs/MyShop/v16/TestStore/0/testlog.manifest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/03/Start_Here/.vs/MyShop/v16/TestStore/0/testlog.manifest -------------------------------------------------------------------------------- /src/04/Start_Here/.vs/MyShop/v16/TestStore/0/testlog.manifest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fekberg/c-sharp-design-patterns-data-access-patterns/HEAD/src/04/Start_Here/.vs/MyShop/v16/TestStore/0/testlog.manifest -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Domain/MyShop.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Domain/MyShop.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Domain/MyShop.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Domain/MyShop.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Domain/MyShop.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Debug", 5 | "System": "Information", 6 | "Microsoft": "Information" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Models/LineItemModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class LineItemModel 6 | { 7 | public Guid ProductId { get; set; } 8 | public int Quantity { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Models/LineItemModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class LineItemModel 6 | { 7 | public Guid ProductId { get; set; } 8 | public int Quantity { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Models/LineItemModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class LineItemModel 6 | { 7 | public Guid ProductId { get; set; } 8 | public int Quantity { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Models/LineItemModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class LineItemModel 6 | { 7 | public Guid ProductId { get; set; } 8 | public int Quantity { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Models/LineItemModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class LineItemModel 6 | { 7 | public Guid ProductId { get; set; } 8 | public int Quantity { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Models/LineItemModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class LineItemModel 6 | { 7 | public Guid ProductId { get; set; } 8 | public int Quantity { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Web.Models 4 | { 5 | public class ErrorViewModel 6 | { 7 | public string RequestId { get; set; } 8 | 9 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Models/CreateOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | 5 | namespace MyShop.Web.Models 6 | { 7 | public class CreateOrderModel 8 | { 9 | public IEnumerable LineItems { get; set; } 10 | 11 | public CustomerModel Customer { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Models/CreateOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | 5 | namespace MyShop.Web.Models 6 | { 7 | public class CreateOrderModel 8 | { 9 | public IEnumerable LineItems { get; set; } 10 | 11 | public CustomerModel Customer { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Models/CreateOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | 5 | namespace MyShop.Web.Models 6 | { 7 | public class CreateOrderModel 8 | { 9 | public IEnumerable LineItems { get; set; } 10 | 11 | public CustomerModel Customer { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Models/CreateOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | 5 | namespace MyShop.Web.Models 6 | { 7 | public class CreateOrderModel 8 | { 9 | public IEnumerable LineItems { get; set; } 10 | 11 | public CustomerModel Customer { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Models/CreateOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | 5 | namespace MyShop.Web.Models 6 | { 7 | public class CreateOrderModel 8 | { 9 | public IEnumerable LineItems { get; set; } 10 | 11 | public CustomerModel Customer { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Models/CreateOrderModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | 5 | namespace MyShop.Web.Models 6 | { 7 | public class CreateOrderModel 8 | { 9 | public IEnumerable LineItems { get; set; } 10 | 11 | public CustomerModel Customer { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Models/CustomerModel.cs: -------------------------------------------------------------------------------- 1 | namespace MyShop.Web.Models 2 | { 3 | public class CustomerModel 4 | { 5 | public string Name { get; set; } 6 | public string ShippingAddress { get; set; } 7 | public string City { get; set; } 8 | public string PostalCode { get; set; } 9 | public string Country { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Models/CustomerModel.cs: -------------------------------------------------------------------------------- 1 | namespace MyShop.Web.Models 2 | { 3 | public class CustomerModel 4 | { 5 | public string Name { get; set; } 6 | public string ShippingAddress { get; set; } 7 | public string City { get; set; } 8 | public string PostalCode { get; set; } 9 | public string Country { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Models/CustomerModel.cs: -------------------------------------------------------------------------------- 1 | namespace MyShop.Web.Models 2 | { 3 | public class CustomerModel 4 | { 5 | public string Name { get; set; } 6 | public string ShippingAddress { get; set; } 7 | public string City { get; set; } 8 | public string PostalCode { get; set; } 9 | public string Country { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Models/CustomerModel.cs: -------------------------------------------------------------------------------- 1 | namespace MyShop.Web.Models 2 | { 3 | public class CustomerModel 4 | { 5 | public string Name { get; set; } 6 | public string ShippingAddress { get; set; } 7 | public string City { get; set; } 8 | public string PostalCode { get; set; } 9 | public string Country { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Models/CustomerModel.cs: -------------------------------------------------------------------------------- 1 | namespace MyShop.Web.Models 2 | { 3 | public class CustomerModel 4 | { 5 | public string Name { get; set; } 6 | public string ShippingAddress { get; set; } 7 | public string City { get; set; } 8 | public string PostalCode { get; set; } 9 | public string Country { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Models/CustomerModel.cs: -------------------------------------------------------------------------------- 1 | namespace MyShop.Web.Models 2 | { 3 | public class CustomerModel 4 | { 5 | public string Name { get; set; } 6 | public string ShippingAddress { get; set; } 7 | public string City { get; set; } 8 | public string PostalCode { get; set; } 9 | public string Country { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Domain/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Product 6 | { 7 | public Guid ProductId { get; private set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public decimal Price { get; set; } 12 | 13 | public Product() 14 | { 15 | ProductId = Guid.NewGuid(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Domain/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Product 6 | { 7 | public Guid ProductId { get; private set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public decimal Price { get; set; } 12 | 13 | public Product() 14 | { 15 | ProductId = Guid.NewGuid(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Domain/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Product 6 | { 7 | public Guid ProductId { get; private set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public decimal Price { get; set; } 12 | 13 | public Product() 14 | { 15 | ProductId = Guid.NewGuid(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Domain/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Product 6 | { 7 | public Guid ProductId { get; private set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public decimal Price { get; set; } 12 | 13 | public Product() 14 | { 15 | ProductId = Guid.NewGuid(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Domain/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Product 6 | { 7 | public Guid ProductId { get; private set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public decimal Price { get; set; } 12 | 13 | public Product() 14 | { 15 | ProductId = Guid.NewGuid(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Domain/Models/Product.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Product 6 | { 7 | public Guid ProductId { get; private set; } 8 | 9 | public string Name { get; set; } 10 | 11 | public decimal Price { get; set; } 12 | 13 | public Product() 14 | { 15 | ProductId = Guid.NewGuid(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/MyShop.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Infrastructure/Repositories/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | 5 | namespace MyShop.Infrastructure.Repositories 6 | { 7 | public interface IRepository 8 | { 9 | T Add(T entity); 10 | T Update(T entity); 11 | T Get(Guid id); 12 | IEnumerable All(); 13 | IEnumerable Find(Expression> predicate); 14 | void SaveChanges(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Infrastructure/Repositories/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | 5 | namespace MyShop.Infrastructure.Repositories 6 | { 7 | public interface IRepository 8 | { 9 | T Add(T entity); 10 | T Update(T entity); 11 | T Get(Guid id); 12 | IEnumerable All(); 13 | IEnumerable Find(Expression> predicate); 14 | void SaveChanges(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Infrastructure/Repositories/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | 5 | namespace MyShop.Infrastructure.Repositories 6 | { 7 | public interface IRepository 8 | { 9 | T Add(T entity); 10 | T Update(T entity); 11 | T Get(Guid id); 12 | IEnumerable All(); 13 | IEnumerable Find(Expression> predicate); 14 | void SaveChanges(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/Repositories/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | 5 | namespace MyShop.Infrastructure.Repositories 6 | { 7 | public interface IRepository 8 | { 9 | T Add(T entity); 10 | T Update(T entity); 11 | T Get(Guid id); 12 | IEnumerable All(); 13 | IEnumerable Find(Expression> predicate); 14 | void SaveChanges(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Infrastructure/Repositories/IRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq.Expressions; 4 | 5 | namespace MyShop.Infrastructure.Repositories 6 | { 7 | public interface IRepository 8 | { 9 | T Add(T entity); 10 | T Update(T entity); 11 | T Get(Guid id); 12 | IEnumerable All(); 13 | IEnumerable Find(Expression> predicate); 14 | void SaveChanges(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Infrastructure/MyShop.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Domain/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Customer 6 | { 7 | public Guid CustomerId { get; set; } 8 | 9 | public string Name { get; set; } 10 | public string ShippingAddress { get; set; } 11 | public string City { get; set; } 12 | public string PostalCode { get; set; } 13 | public string Country { get; set; } 14 | 15 | public Customer() 16 | { 17 | CustomerId = Guid.NewGuid(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Infrastructure/MyShop.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Domain/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Customer 6 | { 7 | public Guid CustomerId { get; set; } 8 | 9 | public string Name { get; set; } 10 | public string ShippingAddress { get; set; } 11 | public string City { get; set; } 12 | public string PostalCode { get; set; } 13 | public string Country { get; set; } 14 | 15 | public Customer() 16 | { 17 | CustomerId = Guid.NewGuid(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Domain/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Customer 6 | { 7 | public Guid CustomerId { get; set; } 8 | 9 | public string Name { get; set; } 10 | public string ShippingAddress { get; set; } 11 | public string City { get; set; } 12 | public string PostalCode { get; set; } 13 | public string Country { get; set; } 14 | 15 | public Customer() 16 | { 17 | CustomerId = Guid.NewGuid(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Infrastructure/MyShop.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Domain/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Customer 6 | { 7 | public Guid CustomerId { get; set; } 8 | 9 | public string Name { get; set; } 10 | public string ShippingAddress { get; set; } 11 | public string City { get; set; } 12 | public string PostalCode { get; set; } 13 | public string Country { get; set; } 14 | 15 | public Customer() 16 | { 17 | CustomerId = Guid.NewGuid(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Infrastructure/MyShop.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/MyShop.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Domain/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class Customer 6 | { 7 | public Guid CustomerId { get; set; } 8 | 9 | public string Name { get; set; } 10 | public string ShippingAddress { get; set; } 11 | public string City { get; set; } 12 | public string PostalCode { get; set; } 13 | public string Country { get; set; } 14 | 15 | public Customer() 16 | { 17 | CustomerId = Guid.NewGuid(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Infrastructure/MyShop.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Domain/Models/LineItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class LineItem 6 | { 7 | public Guid LineItemId { get; set; } 8 | 9 | public int Quantity { get; set; } 10 | 11 | public virtual Product Product { get; set; } 12 | public Guid ProductId { get; set; } 13 | 14 | public virtual Order Order { get; set; } 15 | public Guid OrderId { get; set; } 16 | 17 | public LineItem() 18 | { 19 | LineItemId = Guid.NewGuid(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Domain/Models/LineItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class LineItem 6 | { 7 | public Guid LineItemId { get; set; } 8 | 9 | public int Quantity { get; set; } 10 | 11 | public virtual Product Product { get; set; } 12 | public Guid ProductId { get; set; } 13 | 14 | public virtual Order Order { get; set; } 15 | public Guid OrderId { get; set; } 16 | 17 | public LineItem() 18 | { 19 | LineItemId = Guid.NewGuid(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Domain/Models/LineItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class LineItem 6 | { 7 | public Guid LineItemId { get; set; } 8 | 9 | public int Quantity { get; set; } 10 | 11 | public virtual Product Product { get; set; } 12 | public Guid ProductId { get; set; } 13 | 14 | public virtual Order Order { get; set; } 15 | public Guid OrderId { get; set; } 16 | 17 | public LineItem() 18 | { 19 | LineItemId = Guid.NewGuid(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Domain/Models/LineItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class LineItem 6 | { 7 | public Guid LineItemId { get; set; } 8 | 9 | public int Quantity { get; set; } 10 | 11 | public virtual Product Product { get; set; } 12 | public Guid ProductId { get; set; } 13 | 14 | public virtual Order Order { get; set; } 15 | public Guid OrderId { get; set; } 16 | 17 | public LineItem() 18 | { 19 | LineItemId = Guid.NewGuid(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Domain/Models/LineItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class LineItem 6 | { 7 | public Guid LineItemId { get; set; } 8 | 9 | public int Quantity { get; set; } 10 | 11 | public virtual Product Product { get; set; } 12 | public Guid ProductId { get; set; } 13 | 14 | public virtual Order Order { get; set; } 15 | public Guid OrderId { get; set; } 16 | 17 | public LineItem() 18 | { 19 | LineItemId = Guid.NewGuid(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Domain/Models/LineItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace MyShop.Domain.Models 4 | { 5 | public class LineItem 6 | { 7 | public Guid LineItemId { get; set; } 8 | 9 | public int Quantity { get; set; } 10 | 11 | public virtual Product Product { get; set; } 12 | public Guid ProductId { get; set; } 13 | 14 | public virtual Order Order { get; set; } 15 | public Guid OrderId { get; set; } 16 | 17 | public LineItem() 18 | { 19 | LineItemId = Guid.NewGuid(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/Lazy/Proxies/CustomerProxy.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace MyShop.Infrastructure.Lazy.Proxies 7 | { 8 | public class CustomerProxy : Customer 9 | { 10 | public override byte[] ProfilePicture 11 | { 12 | get 13 | { 14 | if (base.ProfilePicture == null) 15 | { 16 | base.ProfilePicture = ProfilePictureService.GetFor(Name); 17 | } 18 | 19 | return base.ProfilePicture; 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Infrastructure/ShoppingContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | public class ShoppingContext : DbContext 7 | { 8 | public DbSet Customers { get; set; } 9 | 10 | public DbSet Orders { get; set; } 11 | 12 | public DbSet Products { get; set; } 13 | 14 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 15 | { 16 | optionsBuilder 17 | // .UseLazyLoadingProxies() 18 | .UseSqlite("Data Source=orders.db"); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Infrastructure/ShoppingContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | 7 | public class ShoppingContext : DbContext 8 | { 9 | public DbSet Customers { get; set; } 10 | 11 | public DbSet Orders { get; set; } 12 | 13 | public DbSet Products { get; set; } 14 | 15 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 16 | { 17 | optionsBuilder 18 | // .UseLazyLoadingProxies() 19 | .UseSqlite("Data Source=orders.db"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Infrastructure/ShoppingContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | 7 | public class ShoppingContext : DbContext 8 | { 9 | public DbSet Customers { get; set; } 10 | 11 | public DbSet Orders { get; set; } 12 | 13 | public DbSet Products { get; set; } 14 | 15 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 16 | { 17 | optionsBuilder 18 | // .UseLazyLoadingProxies() 19 | .UseSqlite("Data Source=orders.db"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Infrastructure/ShoppingContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | 7 | public class ShoppingContext : DbContext 8 | { 9 | public DbSet Customers { get; set; } 10 | 11 | public DbSet Orders { get; set; } 12 | 13 | public DbSet Products { get; set; } 14 | 15 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 16 | { 17 | optionsBuilder 18 | // .UseLazyLoadingProxies() 19 | .UseSqlite("Data Source=orders.db"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Infrastructure/ShoppingContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | 7 | public class ShoppingContext : DbContext 8 | { 9 | public DbSet Customers { get; set; } 10 | 11 | public DbSet Orders { get; set; } 12 | 13 | public DbSet Products { get; set; } 14 | 15 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 16 | { 17 | optionsBuilder 18 | // .UseLazyLoadingProxies() 19 | .UseSqlite("Data Source=orders.db"); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/MyShop.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 437e0faf-f841-4b9e-bea3-562e13b5eeac 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/MyShop.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 437e0faf-f841-4b9e-bea3-562e13b5eeac 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/MyShop.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 437e0faf-f841-4b9e-bea3-562e13b5eeac 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/MyShop.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 437e0faf-f841-4b9e-bea3-562e13b5eeac 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/MyShop.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp2.1 5 | 437e0faf-f841-4b9e-bea3-562e13b5eeac 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Infrastructure/Repositories/ProductRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class ProductRepository : GenericRepository 7 | { 8 | public ProductRepository(ShoppingContext context) : base(context) 9 | { 10 | 11 | } 12 | public override Product Update(Product entity) 13 | { 14 | var product = context.Products 15 | .Single(p => p.ProductId == entity.ProductId); 16 | 17 | product.Price = entity.Price; 18 | product.Name = entity.Name; 19 | 20 | return base.Update(product); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Infrastructure/Repositories/ProductRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class ProductRepository : GenericRepository 7 | { 8 | public ProductRepository(ShoppingContext context) : base(context) 9 | { 10 | 11 | } 12 | public override Product Update(Product entity) 13 | { 14 | var product = context.Products 15 | .Single(p => p.ProductId == entity.ProductId); 16 | 17 | product.Price = entity.Price; 18 | product.Name = entity.Name; 19 | 20 | return base.Update(product); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Infrastructure/Repositories/ProductRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class ProductRepository : GenericRepository 7 | { 8 | public ProductRepository(ShoppingContext context) : base(context) 9 | { 10 | 11 | } 12 | public override Product Update(Product entity) 13 | { 14 | var product = context.Products 15 | .Single(p => p.ProductId == entity.ProductId); 16 | 17 | product.Price = entity.Price; 18 | product.Name = entity.Name; 19 | 20 | return base.Update(product); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/Repositories/ProductRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class ProductRepository : GenericRepository 7 | { 8 | public ProductRepository(ShoppingContext context) : base(context) 9 | { 10 | 11 | } 12 | public override Product Update(Product entity) 13 | { 14 | var product = context.Products 15 | .Single(p => p.ProductId == entity.ProductId); 16 | 17 | product.Price = entity.Price; 18 | product.Name = entity.Name; 19 | 20 | return base.Update(product); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Infrastructure/Repositories/ProductRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class ProductRepository : GenericRepository 7 | { 8 | public ProductRepository(ShoppingContext context) : base(context) 9 | { 10 | 11 | } 12 | public override Product Update(Product entity) 13 | { 14 | var product = context.Products 15 | .Single(p => p.ProductId == entity.ProductId); 16 | 17 | product.Price = entity.Price; 18 | product.Name = entity.Name; 19 | 20 | return base.Update(product); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace MyShop.Web 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace MyShop.Web 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace MyShop.Web 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace MyShop.Web 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | using Microsoft.AspNetCore; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.Extensions.Configuration; 9 | using Microsoft.Extensions.Logging; 10 | 11 | namespace MyShop.Web 12 | { 13 | public class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | CreateWebHostBuilder(args).Build().Run(); 18 | } 19 | 20 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 21 | WebHost.CreateDefaultBuilder(args) 22 | .UseStartup(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Domain/Models/Customer.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Lazy; 2 | using System; 3 | 4 | namespace MyShop.Domain.Models 5 | { 6 | public class Customer 7 | { 8 | public Guid CustomerId { get; set; } 9 | 10 | // Virtual because a proxy can now override its behaviour 11 | public virtual string Name { get; set; } 12 | public virtual string ShippingAddress { get; set; } 13 | public virtual string City { get; set; } 14 | public virtual string PostalCode { get; set; } 15 | public virtual string Country { get; set; } 16 | 17 | public virtual byte[] ProfilePicture { get; set; } 18 | 19 | public Customer() 20 | { 21 | CustomerId = Guid.NewGuid(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Domain/Lazy/ValueHolder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace MyShop.Domain.Lazy 6 | { 7 | public interface IValueHolder 8 | { 9 | T GetValue(object parameter); 10 | } 11 | public class ValueHolder : IValueHolder 12 | { 13 | private readonly Func getValue; 14 | private T value; 15 | 16 | public ValueHolder(Func getValue) 17 | { 18 | this.getValue = getValue; 19 | } 20 | 21 | public T GetValue(object parameter) 22 | { 23 | if(value == null) 24 | { 25 | value = getValue(parameter); 26 | } 27 | 28 | return value; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Domain/Models/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace MyShop.Domain.Models 6 | { 7 | public class Order 8 | { 9 | public Guid OrderId { get; private set; } 10 | 11 | public virtual ICollection LineItems { get; set; } 12 | 13 | public virtual Customer Customer { get; set; } 14 | public Guid CustomerId { get; set; } 15 | 16 | // SQLite doesn't support DateTimeOffset :( 17 | public DateTime OrderDate { get; set; } 18 | 19 | public decimal OrderTotal => LineItems.Sum(item => item.Product.Price * item.Quantity); 20 | 21 | public Order() 22 | { 23 | OrderId = Guid.NewGuid(); 24 | 25 | OrderDate = DateTime.UtcNow; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Domain/Models/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace MyShop.Domain.Models 6 | { 7 | public class Order 8 | { 9 | public Guid OrderId { get; private set; } 10 | 11 | public virtual ICollection LineItems { get; set; } 12 | 13 | public virtual Customer Customer { get; set; } 14 | public Guid CustomerId { get; set; } 15 | 16 | // SQLite doesn't support DateTimeOffset :( 17 | public DateTime OrderDate { get; set; } 18 | 19 | public decimal OrderTotal => LineItems.Sum(item => item.Product.Price * item.Quantity); 20 | 21 | public Order() 22 | { 23 | OrderId = Guid.NewGuid(); 24 | 25 | OrderDate = DateTime.UtcNow; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Domain/Models/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace MyShop.Domain.Models 6 | { 7 | public class Order 8 | { 9 | public Guid OrderId { get; private set; } 10 | 11 | public virtual ICollection LineItems { get; set; } 12 | 13 | public virtual Customer Customer { get; set; } 14 | public Guid CustomerId { get; set; } 15 | 16 | // SQLite doesn't support DateTimeOffset :( 17 | public DateTime OrderDate { get; set; } 18 | 19 | public decimal OrderTotal => LineItems.Sum(item => item.Product.Price * item.Quantity); 20 | 21 | public Order() 22 | { 23 | OrderId = Guid.NewGuid(); 24 | 25 | OrderDate = DateTime.UtcNow; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Domain/Models/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace MyShop.Domain.Models 6 | { 7 | public class Order 8 | { 9 | public Guid OrderId { get; private set; } 10 | 11 | public virtual ICollection LineItems { get; set; } 12 | 13 | public virtual Customer Customer { get; set; } 14 | public Guid CustomerId { get; set; } 15 | 16 | // SQLite doesn't support DateTimeOffset :( 17 | public DateTime OrderDate { get; set; } 18 | 19 | public decimal OrderTotal => LineItems.Sum(item => item.Product.Price * item.Quantity); 20 | 21 | public Order() 22 | { 23 | OrderId = Guid.NewGuid(); 24 | 25 | OrderDate = DateTime.UtcNow; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Domain/Models/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace MyShop.Domain.Models 6 | { 7 | public class Order 8 | { 9 | public Guid OrderId { get; private set; } 10 | 11 | public virtual ICollection LineItems { get; set; } 12 | 13 | public virtual Customer Customer { get; set; } 14 | public Guid CustomerId { get; set; } 15 | 16 | // SQLite doesn't support DateTimeOffset :( 17 | public DateTime OrderDate { get; set; } 18 | 19 | public decimal OrderTotal => LineItems.Sum(item => item.Product.Price * item.Quantity); 20 | 21 | public Order() 22 | { 23 | OrderId = Guid.NewGuid(); 24 | 25 | OrderDate = DateTime.UtcNow; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Domain/Models/Order.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | 5 | namespace MyShop.Domain.Models 6 | { 7 | public class Order 8 | { 9 | public Guid OrderId { get; private set; } 10 | 11 | public virtual ICollection LineItems { get; set; } 12 | 13 | public virtual Customer Customer { get; set; } 14 | public Guid CustomerId { get; set; } 15 | 16 | // SQLite doesn't support DateTimeOffset :( 17 | public DateTime OrderDate { get; set; } 18 | 19 | public decimal OrderTotal => LineItems.Sum(item => item.Product.Price * item.Quantity); 20 | 21 | public Order() 22 | { 23 | OrderId = Guid.NewGuid(); 24 | 25 | OrderDate = DateTime.UtcNow; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Views/Customer/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All customers"; 5 | } 6 | 7 |

Customers

8 | 9 | @foreach (var customer in Model) 10 | { 11 |
12 |
13 |

14 | Customer 15 | @customer.Name 16 |

17 |
18 |

@customer.ShippingAddress

19 |

@customer.City

20 |

@customer.PostalCode

21 |

@customer.Country

22 |
23 | More details 24 |
25 |
26 | } -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Controllers/CustomerController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Microsoft.AspNetCore.Mvc; 4 | using MyShop.Infrastructure; 5 | 6 | namespace MyShop.Web.Controllers 7 | { 8 | public class CustomerController : Controller 9 | { 10 | private ShoppingContext context; 11 | 12 | public CustomerController() 13 | { 14 | context = new ShoppingContext(); 15 | } 16 | 17 | public IActionResult Index(Guid? id) 18 | { 19 | if (id == null) 20 | { 21 | var customers = context.Customers.ToList(); 22 | 23 | return View(customers); 24 | } 25 | else 26 | { 27 | var customer = context.Customers.Find(id.Value); 28 | 29 | return View(new[] { customer }); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Views/Customer/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All customers"; 5 | } 6 | 7 |

Customers

8 | 9 | @foreach (var customer in Model) 10 | { 11 |
12 |
13 |

14 | Customer 15 | @customer.Name 16 |

17 |
18 |

@customer.ShippingAddress

19 |

@customer.City

20 |

@customer.PostalCode

21 |

@customer.Country

22 |
23 | More details 24 |
25 |
26 | } -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Infrastructure/Repositories/CustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class CustomerRepository : GenericRepository 7 | { 8 | public CustomerRepository(ShoppingContext context) : base(context) 9 | { 10 | } 11 | 12 | public override Customer Update(Customer entity) 13 | { 14 | var customer = context.Customers 15 | .Single(c => c.CustomerId == entity.CustomerId); 16 | 17 | customer.Name = entity.Name; 18 | customer.City = entity.City; 19 | customer.PostalCode = entity.PostalCode; 20 | customer.ShippingAddress = entity.ShippingAddress; 21 | customer.Country = entity.Country; 22 | 23 | return base.Update(customer); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Views/Customer/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All customers"; 5 | } 6 | 7 |

Customers

8 | 9 | @foreach (var customer in Model) 10 | { 11 |
12 |
13 |

14 | Customer 15 | @customer.Name 16 |

17 |
18 |

@customer.ShippingAddress

19 |

@customer.City

20 |

@customer.PostalCode

21 |

@customer.Country

22 |
23 | More details 24 |
25 |
26 | } -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Infrastructure/Repositories/CustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class CustomerRepository : GenericRepository 7 | { 8 | public CustomerRepository(ShoppingContext context) : base(context) 9 | { 10 | } 11 | 12 | public override Customer Update(Customer entity) 13 | { 14 | var customer = context.Customers 15 | .Single(c => c.CustomerId == entity.CustomerId); 16 | 17 | customer.Name = entity.Name; 18 | customer.City = entity.City; 19 | customer.PostalCode = entity.PostalCode; 20 | customer.ShippingAddress = entity.ShippingAddress; 21 | customer.Country = entity.Country; 22 | 23 | return base.Update(customer); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Infrastructure/Repositories/CustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class CustomerRepository : GenericRepository 7 | { 8 | public CustomerRepository(ShoppingContext context) : base(context) 9 | { 10 | } 11 | 12 | public override Customer Update(Customer entity) 13 | { 14 | var customer = context.Customers 15 | .Single(c => c.CustomerId == entity.CustomerId); 16 | 17 | customer.Name = entity.Name; 18 | customer.City = entity.City; 19 | customer.PostalCode = entity.PostalCode; 20 | customer.ShippingAddress = entity.ShippingAddress; 21 | customer.Country = entity.Country; 22 | 23 | return base.Update(customer); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Views/Customer/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All customers"; 5 | } 6 | 7 |

Customers

8 | 9 | @foreach (var customer in Model) 10 | { 11 |
12 |
13 |

14 | Customer 15 | @customer.Name 16 |

17 |
18 |

@customer.ShippingAddress

19 |

@customer.City

20 |

@customer.PostalCode

21 |

@customer.Country

22 |
23 | More details 24 |
25 |
26 | } -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Infrastructure/Repositories/CustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using System.Linq; 3 | 4 | namespace MyShop.Infrastructure.Repositories 5 | { 6 | public class CustomerRepository : GenericRepository 7 | { 8 | public CustomerRepository(ShoppingContext context) : base(context) 9 | { 10 | } 11 | 12 | public override Customer Update(Customer entity) 13 | { 14 | var customer = context.Customers 15 | .Single(c => c.CustomerId == entity.CustomerId); 16 | 17 | customer.Name = entity.Name; 18 | customer.City = entity.City; 19 | customer.PostalCode = entity.PostalCode; 20 | customer.ShippingAddress = entity.ShippingAddress; 21 | customer.Country = entity.Country; 22 | 23 | return base.Update(customer); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Views/Customer/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All customers"; 5 | } 6 | 7 |

Customers

8 | 9 | @foreach (var customer in Model) 10 | { 11 |
12 |
13 |

14 | Customer 15 | @customer.Name 16 |

17 |
18 |

@customer.ShippingAddress

19 |

@customer.City

20 |

@customer.PostalCode

21 |

@customer.Country

22 |
23 | More details 24 |
25 |
26 | } -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/ShoppingContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | 7 | public class ShoppingContext : DbContext 8 | { 9 | public DbSet Customers { get; set; } 10 | 11 | public DbSet Orders { get; set; } 12 | 13 | public DbSet Products { get; set; } 14 | 15 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) 16 | { 17 | optionsBuilder 18 | .UseLazyLoadingProxies() 19 | .UseSqlite("Data Source=orders.db"); 20 | } 21 | 22 | protected override void OnModelCreating(ModelBuilder modelBuilder) 23 | { 24 | modelBuilder.Entity() 25 | .Ignore(c => c.ProfilePicture); 26 | 27 | base.OnModelCreating(modelBuilder); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web.Tests/MyShop.Web.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Controllers/CustomerController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc; 3 | using MyShop.Domain.Models; 4 | using MyShop.Infrastructure.Repositories; 5 | 6 | namespace MyShop.Web.Controllers 7 | { 8 | public class CustomerController : Controller 9 | { 10 | private readonly IRepository repository; 11 | 12 | public CustomerController(IRepository repository) 13 | { 14 | this.repository = repository; 15 | } 16 | 17 | public IActionResult Index(Guid? id) 18 | { 19 | if (id == null) 20 | { 21 | var customers = repository.All(); 22 | 23 | return View(customers); 24 | } 25 | else 26 | { 27 | var customer = repository.Get(id.Value); 28 | 29 | return View(new[] { customer }); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web.Tests/MyShop.Web.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Controllers/CustomerController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc; 3 | using MyShop.Domain.Models; 4 | using MyShop.Infrastructure.Repositories; 5 | 6 | namespace MyShop.Web.Controllers 7 | { 8 | public class CustomerController : Controller 9 | { 10 | private readonly IRepository repository; 11 | 12 | public CustomerController(IRepository repository) 13 | { 14 | this.repository = repository; 15 | } 16 | 17 | public IActionResult Index(Guid? id) 18 | { 19 | if (id == null) 20 | { 21 | var customers = repository.All(); 22 | 23 | return View(customers); 24 | } 25 | else 26 | { 27 | var customer = repository.Get(id.Value); 28 | 29 | return View(new[] { customer }); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web.Tests/MyShop.Web.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Controllers/CustomerController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc; 3 | using MyShop.Domain.Models; 4 | using MyShop.Infrastructure.Repositories; 5 | 6 | namespace MyShop.Web.Controllers 7 | { 8 | public class CustomerController : Controller 9 | { 10 | private readonly IRepository repository; 11 | 12 | public CustomerController(IRepository repository) 13 | { 14 | this.repository = repository; 15 | } 16 | 17 | public IActionResult Index(Guid? id) 18 | { 19 | if (id == null) 20 | { 21 | var customers = repository.All(); 22 | 23 | return View(customers); 24 | } 25 | else 26 | { 27 | var customer = repository.Get(id.Value); 28 | 29 | return View(new[] { customer }); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web.Tests/MyShop.Web.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Controllers/CustomerController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc; 3 | using MyShop.Domain.Models; 4 | using MyShop.Infrastructure.Repositories; 5 | 6 | namespace MyShop.Web.Controllers 7 | { 8 | public class CustomerController : Controller 9 | { 10 | private readonly IRepository repository; 11 | 12 | public CustomerController(IRepository repository) 13 | { 14 | this.repository = repository; 15 | } 16 | 17 | public IActionResult Index(Guid? id) 18 | { 19 | if (id == null) 20 | { 21 | var customers = repository.All(); 22 | 23 | return View(customers); 24 | } 25 | else 26 | { 27 | var customer = repository.Get(id.Value); 28 | 29 | return View(new[] { customer }); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web.Tests/MyShop.Web.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netcoreapp3.1 5 | 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Controllers/CustomerController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.AspNetCore.Mvc; 3 | using MyShop.Domain.Models; 4 | using MyShop.Infrastructure.Repositories; 5 | 6 | namespace MyShop.Web.Controllers 7 | { 8 | public class CustomerController : Controller 9 | { 10 | private readonly IRepository repository; 11 | 12 | public CustomerController(IRepository repository) 13 | { 14 | this.repository = repository; 15 | } 16 | 17 | public IActionResult Index(Guid? id) 18 | { 19 | if (id == null) 20 | { 21 | var customers = repository.All(); 22 | 23 | return View(customers); 24 | } 25 | else 26 | { 27 | var customer = repository.Get(id.Value); 28 | 29 | return View(new[] { customer }); 30 | } 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/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 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/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 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/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 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/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 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/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 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/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 | Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. 22 |

23 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Views/Customer/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All customers"; 5 | } 6 | 7 |

Customers

8 | 9 | @foreach (var customer in Model) 10 | { 11 |
12 |
13 |

14 | Customer 15 | @customer.Name 16 |

17 | 18 |
19 |

@customer.ShippingAddress

20 |

@customer.City

21 |

@customer.PostalCode

22 |

@customer.Country

23 |
24 | More details 25 |
26 |
27 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Filip Ekberg 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Infrastructure/Repositories/OrderRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | 8 | namespace MyShop.Infrastructure.Repositories 9 | { 10 | public class OrderRepository : GenericRepository 11 | { 12 | public OrderRepository(ShoppingContext context) : base(context) 13 | { 14 | } 15 | 16 | public override IEnumerable Find(Expression> predicate) 17 | { 18 | return context.Orders 19 | .Include(order => order.LineItems) 20 | .ThenInclude(lineItem => lineItem.Product) 21 | .Where(predicate).ToList(); 22 | } 23 | 24 | public override Order Update(Order entity) 25 | { 26 | var order = context.Orders 27 | .Include(o => o.LineItems) 28 | .ThenInclude(lineItem => lineItem.Product) 29 | .Single(o => o.OrderId == entity.OrderId); 30 | 31 | order.OrderDate = entity.OrderDate; 32 | order.LineItems = entity.LineItems; 33 | 34 | return base.Update(order); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Infrastructure/Repositories/OrderRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | 8 | namespace MyShop.Infrastructure.Repositories 9 | { 10 | public class OrderRepository : GenericRepository 11 | { 12 | public OrderRepository(ShoppingContext context) : base(context) 13 | { 14 | } 15 | 16 | public override IEnumerable Find(Expression> predicate) 17 | { 18 | return context.Orders 19 | .Include(order => order.LineItems) 20 | .ThenInclude(lineItem => lineItem.Product) 21 | .Where(predicate).ToList(); 22 | } 23 | 24 | public override Order Update(Order entity) 25 | { 26 | var order = context.Orders 27 | .Include(o => o.LineItems) 28 | .ThenInclude(lineItem => lineItem.Product) 29 | .Single(o => o.OrderId == entity.OrderId); 30 | 31 | order.OrderDate = entity.OrderDate; 32 | order.LineItems = entity.LineItems; 33 | 34 | return base.Update(order); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Infrastructure/Repositories/OrderRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | 8 | namespace MyShop.Infrastructure.Repositories 9 | { 10 | public class OrderRepository : GenericRepository 11 | { 12 | public OrderRepository(ShoppingContext context) : base(context) 13 | { 14 | } 15 | 16 | public override IEnumerable Find(Expression> predicate) 17 | { 18 | return context.Orders 19 | .Include(order => order.LineItems) 20 | .ThenInclude(lineItem => lineItem.Product) 21 | .Where(predicate).ToList(); 22 | } 23 | 24 | public override Order Update(Order entity) 25 | { 26 | var order = context.Orders 27 | .Include(o => o.LineItems) 28 | .ThenInclude(lineItem => lineItem.Product) 29 | .Single(o => o.OrderId == entity.OrderId); 30 | 31 | order.OrderDate = entity.OrderDate; 32 | order.LineItems = entity.LineItems; 33 | 34 | return base.Update(order); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/Repositories/OrderRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | 8 | namespace MyShop.Infrastructure.Repositories 9 | { 10 | public class OrderRepository : GenericRepository 11 | { 12 | public OrderRepository(ShoppingContext context) : base(context) 13 | { 14 | } 15 | 16 | public override IEnumerable Find(Expression> predicate) 17 | { 18 | return context.Orders 19 | .Include(order => order.LineItems) 20 | .ThenInclude(lineItem => lineItem.Product) 21 | .Where(predicate).ToList(); 22 | } 23 | 24 | public override Order Update(Order entity) 25 | { 26 | var order = context.Orders 27 | .Include(o => o.LineItems) 28 | .ThenInclude(lineItem => lineItem.Product) 29 | .Single(o => o.OrderId == entity.OrderId); 30 | 31 | order.OrderDate = entity.OrderDate; 32 | order.LineItems = entity.LineItems; 33 | 34 | return base.Update(order); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Infrastructure/Repositories/OrderRepository.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using MyShop.Domain.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Linq.Expressions; 7 | 8 | namespace MyShop.Infrastructure.Repositories 9 | { 10 | public class OrderRepository : GenericRepository 11 | { 12 | public OrderRepository(ShoppingContext context) : base(context) 13 | { 14 | } 15 | 16 | public override IEnumerable Find(Expression> predicate) 17 | { 18 | return context.Orders 19 | .Include(order => order.LineItems) 20 | .ThenInclude(lineItem => lineItem.Product) 21 | .Where(predicate).ToList(); 22 | } 23 | 24 | public override Order Update(Order entity) 25 | { 26 | var order = context.Orders 27 | .Include(o => o.LineItems) 28 | .ThenInclude(lineItem => lineItem.Product) 29 | .Single(o => o.OrderId == entity.OrderId); 30 | 31 | order.OrderDate = entity.OrderDate; 32 | order.LineItems = entity.LineItems; 33 | 34 | return base.Update(order); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Views/Order/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All orders"; 5 | } 6 | 7 |

Orders

8 | 9 | @foreach (var order in Model) 10 | { 11 |
12 |
13 |

14 | Order # 15 | @order.OrderId 16 |

17 |
    18 | @foreach (var item in order.LineItems) 19 | { 20 |
  • 21 |
    22 |
    @item.Product.Name
    23 | Quantity: @item.Quantity 24 |
    25 | $@(item.Product.Price * item.Quantity) 26 |
  • 27 | } 28 | 29 |
  • 30 | Total (USD) 31 | $@order.OrderTotal 32 |
  • 33 |
34 |
35 |
36 | } -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Views/Order/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All orders"; 5 | } 6 | 7 |

Orders

8 | 9 | @foreach (var order in Model) 10 | { 11 |
12 |
13 |

14 | Order # 15 | @order.OrderId 16 |

17 |
    18 | @foreach (var item in order.LineItems) 19 | { 20 |
  • 21 |
    22 |
    @item.Product.Name
    23 | Quantity: @item.Quantity 24 |
    25 | $@(item.Product.Price * item.Quantity) 26 |
  • 27 | } 28 | 29 |
  • 30 | Total (USD) 31 | $@order.OrderTotal 32 |
  • 33 |
34 |
35 |
36 | } -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Views/Order/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All orders"; 5 | } 6 | 7 |

Orders

8 | 9 | @foreach (var order in Model) 10 | { 11 |
12 |
13 |

14 | Order # 15 | @order.OrderId 16 |

17 |
    18 | @foreach (var item in order.LineItems) 19 | { 20 |
  • 21 |
    22 |
    @item.Product.Name
    23 | Quantity: @item.Quantity 24 |
    25 | $@(item.Product.Price * item.Quantity) 26 |
  • 27 | } 28 | 29 |
  • 30 | Total (USD) 31 | $@order.OrderTotal 32 |
  • 33 |
34 |
35 |
36 | } -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Views/Order/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All orders"; 5 | } 6 | 7 |

Orders

8 | 9 | @foreach (var order in Model) 10 | { 11 |
12 |
13 |

14 | Order # 15 | @order.OrderId 16 |

17 |
    18 | @foreach (var item in order.LineItems) 19 | { 20 |
  • 21 |
    22 |
    @item.Product.Name
    23 | Quantity: @item.Quantity 24 |
    25 | $@(item.Product.Price * item.Quantity) 26 |
  • 27 | } 28 | 29 |
  • 30 | Total (USD) 31 | $@order.OrderTotal 32 |
  • 33 |
34 |
35 |
36 | } -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Views/Order/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All orders"; 5 | } 6 | 7 |

Orders

8 | 9 | @foreach (var order in Model) 10 | { 11 |
12 |
13 |

14 | Order # 15 | @order.OrderId 16 |

17 |
    18 | @foreach (var item in order.LineItems) 19 | { 20 |
  • 21 |
    22 |
    @item.Product.Name
    23 | Quantity: @item.Quantity 24 |
    25 | $@(item.Product.Price * item.Quantity) 26 |
  • 27 | } 28 | 29 |
  • 30 | Total (USD) 31 | $@order.OrderTotal 32 |
  • 33 |
34 |
35 |
36 | } -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Views/Order/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | 3 | @{ 4 | ViewData["Title"] = "All orders"; 5 | } 6 | 7 |

Orders

8 | 9 | @foreach (var order in Model) 10 | { 11 |
12 |
13 |

14 | Order # 15 | @order.OrderId 16 |

17 |
    18 | @foreach (var item in order.LineItems) 19 | { 20 |
  • 21 |
    22 |
    @item.Product.Name
    23 | Quantity: @item.Quantity 24 |
    25 | $@(item.Product.Price * item.Quantity) 26 |
  • 27 | } 28 | 29 |
  • 30 | Total (USD) 31 | $@order.OrderTotal 32 |
  • 33 |
34 |
35 |
36 | } -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Infrastructure/Repositories/GenericRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | 6 | namespace MyShop.Infrastructure.Repositories 7 | { 8 | public abstract class GenericRepository 9 | : IRepository where T : class 10 | { 11 | protected ShoppingContext context; 12 | 13 | public GenericRepository(ShoppingContext context) 14 | { 15 | this.context = context; 16 | } 17 | 18 | public virtual T Add(T entity) 19 | { 20 | return context 21 | .Add(entity) 22 | .Entity; 23 | } 24 | 25 | public virtual IEnumerable Find(Expression> predicate) 26 | { 27 | return context.Set() 28 | .AsQueryable() 29 | .Where(predicate).ToList(); 30 | } 31 | 32 | public virtual T Get(Guid id) 33 | { 34 | return context.Find(id); 35 | } 36 | 37 | public virtual IEnumerable All() 38 | { 39 | return context.Set() 40 | .ToList(); 41 | } 42 | 43 | public virtual T Update(T entity) 44 | { 45 | return context.Update(entity) 46 | .Entity; 47 | } 48 | 49 | public void SaveChanges() 50 | { 51 | context.SaveChanges(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Infrastructure/Repositories/GenericRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | 6 | namespace MyShop.Infrastructure.Repositories 7 | { 8 | public abstract class GenericRepository : IRepository where T : class 9 | { 10 | protected ShoppingContext context; 11 | 12 | public GenericRepository(ShoppingContext context) 13 | { 14 | this.context = context; 15 | } 16 | 17 | public virtual T Add(T entity) 18 | { 19 | return context 20 | .Add(entity) 21 | .Entity; 22 | } 23 | 24 | public virtual IEnumerable Find(Expression> predicate) 25 | { 26 | return context.Set() 27 | .AsQueryable() 28 | .Where(predicate).ToList(); 29 | } 30 | 31 | public virtual T Get(Guid id) 32 | { 33 | return context.Find(id); 34 | } 35 | 36 | public virtual IEnumerable All() 37 | { 38 | return context.Set() 39 | .AsQueryable() 40 | .ToList(); 41 | } 42 | 43 | public virtual T Update(T entity) 44 | { 45 | return context.Update(entity) 46 | .Entity; 47 | } 48 | 49 | public void SaveChanges() 50 | { 51 | context.SaveChanges(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Infrastructure/Repositories/GenericRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | 6 | namespace MyShop.Infrastructure.Repositories 7 | { 8 | public abstract class GenericRepository : IRepository where T : class 9 | { 10 | protected ShoppingContext context; 11 | 12 | public GenericRepository(ShoppingContext context) 13 | { 14 | this.context = context; 15 | } 16 | 17 | public virtual T Add(T entity) 18 | { 19 | return context 20 | .Add(entity) 21 | .Entity; 22 | } 23 | 24 | public virtual IEnumerable Find(Expression> predicate) 25 | { 26 | return context.Set() 27 | .AsQueryable() 28 | .Where(predicate).ToList(); 29 | } 30 | 31 | public virtual T Get(Guid id) 32 | { 33 | return context.Find(id); 34 | } 35 | 36 | public virtual IEnumerable All() 37 | { 38 | return context.Set() 39 | .AsQueryable() 40 | .ToList(); 41 | } 42 | 43 | public virtual T Update(T entity) 44 | { 45 | return context.Update(entity) 46 | .Entity; 47 | } 48 | 49 | public void SaveChanges() 50 | { 51 | context.SaveChanges(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/Repositories/GenericRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | 6 | namespace MyShop.Infrastructure.Repositories 7 | { 8 | public abstract class GenericRepository : IRepository where T : class 9 | { 10 | protected ShoppingContext context; 11 | 12 | public GenericRepository(ShoppingContext context) 13 | { 14 | this.context = context; 15 | } 16 | 17 | public virtual T Add(T entity) 18 | { 19 | return context 20 | .Add(entity) 21 | .Entity; 22 | } 23 | 24 | public virtual IEnumerable Find(Expression> predicate) 25 | { 26 | return context.Set() 27 | .AsQueryable() 28 | .Where(predicate).ToList(); 29 | } 30 | 31 | public virtual T Get(Guid id) 32 | { 33 | return context.Find(id); 34 | } 35 | 36 | public virtual IEnumerable All() 37 | { 38 | return context.Set() 39 | .AsQueryable() 40 | .ToList(); 41 | } 42 | 43 | public virtual T Update(T entity) 44 | { 45 | return context.Update(entity) 46 | .Entity; 47 | } 48 | 49 | public void SaveChanges() 50 | { 51 | context.SaveChanges(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Infrastructure/Repositories/GenericRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | 6 | namespace MyShop.Infrastructure.Repositories 7 | { 8 | public abstract class GenericRepository : IRepository where T : class 9 | { 10 | protected ShoppingContext context; 11 | 12 | public GenericRepository(ShoppingContext context) 13 | { 14 | this.context = context; 15 | } 16 | 17 | public virtual T Add(T entity) 18 | { 19 | return context 20 | .Add(entity) 21 | .Entity; 22 | } 23 | 24 | public virtual IEnumerable Find(Expression> predicate) 25 | { 26 | return context.Set() 27 | .AsQueryable() 28 | .Where(predicate).ToList(); 29 | } 30 | 31 | public virtual T Get(Guid id) 32 | { 33 | return context.Find(id); 34 | } 35 | 36 | public virtual IEnumerable All() 37 | { 38 | return context.Set() 39 | .AsQueryable() 40 | .ToList(); 41 | } 42 | 43 | public virtual T Update(T entity) 44 | { 45 | return context.Update(entity) 46 | .Entity; 47 | } 48 | 49 | public void SaveChanges() 50 | { 51 | context.SaveChanges(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/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 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Program.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using MyShop.Infrastructure; 3 | 4 | var builder = WebApplication.CreateBuilder(args); 5 | 6 | // Add services to the container. 7 | builder.Services.AddControllersWithViews(); 8 | 9 | var app = builder.Build(); 10 | 11 | CreateInitialDatabase(); 12 | 13 | // Configure the HTTP request pipeline. 14 | if (!app.Environment.IsDevelopment()) 15 | { 16 | app.UseExceptionHandler("/Order/Error"); 17 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 18 | app.UseHsts(); 19 | } 20 | 21 | app.UseHttpsRedirection(); 22 | app.UseStaticFiles(); 23 | 24 | app.UseRouting(); 25 | 26 | app.UseAuthorization(); 27 | 28 | app.MapControllerRoute( 29 | name: "default", 30 | pattern: "{controller=Order}/{action=Index}/{id?}"); 31 | 32 | app.Run(); 33 | 34 | 35 | void CreateInitialDatabase() 36 | { 37 | using (var context = new ShoppingContext()) 38 | { 39 | context.Database.EnsureDeleted(); 40 | context.Database.EnsureCreated(); 41 | 42 | var camera = new Product { Name = "Canon EOS 70D", Price = 599m }; 43 | var microphone = new Product { Name = "Shure SM7B", Price = 245m }; 44 | var light = new Product { Name = "Key Light", Price = 59.99m }; 45 | var phone = new Product { Name = "Android Phone", Price = 259.59m }; 46 | var speakers = new Product { Name = "5.1 Speaker System", Price = 799.99m }; 47 | 48 | context.Products.Add(camera); 49 | context.Products.Add(microphone); 50 | context.Products.Add(light); 51 | context.Products.Add(phone); 52 | context.Products.Add(speakers); 53 | 54 | context.SaveChanges(); 55 | } 56 | } -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web.Tests/OrderControllerTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using Moq; 3 | using MyShop.Domain.Models; 4 | using MyShop.Infrastructure.Repositories; 5 | using MyShop.Web.Controllers; 6 | using MyShop.Web.Models; 7 | using System; 8 | 9 | namespace MyShop.Web.Tests 10 | { 11 | [TestClass] 12 | public class OrderControllerTests 13 | { 14 | [TestMethod] 15 | public void CanCreateOrderWithCorrectModel() 16 | { 17 | // ARRANGE 18 | var orderRepository = new Mock>(); 19 | var productRepository = new Mock>(); 20 | var customerRepository = new Mock>(); 21 | 22 | var orderController = new OrderController( 23 | orderRepository.Object, 24 | productRepository.Object 25 | ); 26 | 27 | var createOrderModel = new CreateOrderModel 28 | { 29 | Customer = new CustomerModel 30 | { 31 | Name = "Filip Ekberg", 32 | ShippingAddress = "Test address", 33 | City = "Gothenburg", 34 | PostalCode = "43317", 35 | Country = "Sweden" 36 | }, 37 | LineItems = new [] 38 | { 39 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 10 }, 40 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 2 }, 41 | } 42 | }; 43 | 44 | // ACT 45 | 46 | orderController.Create(createOrderModel); 47 | 48 | // ASSERT 49 | 50 | orderRepository.Verify(r => r.Add(It.IsAny()), Times.AtLeastOnce()); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web.Tests/OrderControllerTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualStudio.TestTools.UnitTesting; 2 | using Moq; 3 | using MyShop.Domain.Models; 4 | using MyShop.Infrastructure.Repositories; 5 | using MyShop.Web.Controllers; 6 | using MyShop.Web.Models; 7 | using System; 8 | 9 | namespace MyShop.Web.Tests 10 | { 11 | [TestClass] 12 | public class OrderControllerTests 13 | { 14 | [TestMethod] 15 | public void CanCreateOrderWithCorrectModel() 16 | { 17 | // ARRANGE 18 | var orderRepository = new Mock>(); 19 | var productRepository = new Mock>(); 20 | var customerRepository = new Mock>(); 21 | 22 | var orderController = new OrderController( 23 | orderRepository.Object, 24 | productRepository.Object 25 | ); 26 | 27 | var createOrderModel = new CreateOrderModel 28 | { 29 | Customer = new CustomerModel 30 | { 31 | Name = "Filip Ekberg", 32 | ShippingAddress = "Test address", 33 | City = "Gothenburg", 34 | PostalCode = "43317", 35 | Country = "Sweden" 36 | }, 37 | LineItems = new [] 38 | { 39 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 10 }, 40 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 2 }, 41 | } 42 | }; 43 | 44 | // ACT 45 | 46 | orderController.Create(createOrderModel); 47 | 48 | // ASSERT 49 | 50 | orderRepository.Verify(r => r.Add(It.IsAny()), 51 | Times.AtLeastOnce()); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Views/Shared/_CookieConsentPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Features 2 | 3 | @{ 4 | var consentFeature = Context.Features.Get(); 5 | var showBanner = !consentFeature?.CanTrack ?? false; 6 | var cookieString = consentFeature?.CreateConsentCookie(); 7 | } 8 | 9 | @if (showBanner) 10 | { 11 | 33 | 41 | } -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Views/Shared/_CookieConsentPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Features 2 | 3 | @{ 4 | var consentFeature = Context.Features.Get(); 5 | var showBanner = !consentFeature?.CanTrack ?? false; 6 | var cookieString = consentFeature?.CreateConsentCookie(); 7 | } 8 | 9 | @if (showBanner) 10 | { 11 | 33 | 41 | } -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web/Views/Shared/_CookieConsentPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Features 2 | 3 | @{ 4 | var consentFeature = Context.Features.Get(); 5 | var showBanner = !consentFeature?.CanTrack ?? false; 6 | var cookieString = consentFeature?.CreateConsentCookie(); 7 | } 8 | 9 | @if (showBanner) 10 | { 11 | 33 | 41 | } -------------------------------------------------------------------------------- /src/03/Start_Here/MyShop.Web/Views/Shared/_CookieConsentPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Features 2 | 3 | @{ 4 | var consentFeature = Context.Features.Get(); 5 | var showBanner = !consentFeature?.CanTrack ?? false; 6 | var cookieString = consentFeature?.CreateConsentCookie(); 7 | } 8 | 9 | @if (showBanner) 10 | { 11 | 33 | 41 | } -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web/Views/Shared/_CookieConsentPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Features 2 | 3 | @{ 4 | var consentFeature = Context.Features.Get(); 5 | var showBanner = !consentFeature?.CanTrack ?? false; 6 | var cookieString = consentFeature?.CreateConsentCookie(); 7 | } 8 | 9 | @if (showBanner) 10 | { 11 | 33 | 41 | } -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web/Views/Shared/_CookieConsentPartial.cshtml: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Http.Features 2 | 3 | @{ 4 | var consentFeature = Context.Features.Get(); 5 | var showBanner = !consentFeature?.CanTrack ?? false; 6 | var cookieString = consentFeature?.CreateConsentCookie(); 7 | } 8 | 9 | @if (showBanner) 10 | { 11 | 33 | 41 | } -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Infrastructure/UnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using MyShop.Infrastructure.Repositories; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | public interface IUnitOfWork 7 | { 8 | IRepository CustomerRepository { get; } 9 | IRepository OrderRepository { get; } 10 | IRepository ProductRepository { get; } 11 | 12 | void SaveChanges(); 13 | } 14 | 15 | public class UnitOfWork : IUnitOfWork 16 | { 17 | private ShoppingContext context; 18 | 19 | public UnitOfWork(ShoppingContext context) 20 | { 21 | this.context = context; 22 | } 23 | 24 | private IRepository customerRepository; 25 | public IRepository CustomerRepository 26 | { 27 | get 28 | { 29 | if (customerRepository == null) 30 | { 31 | customerRepository = new CustomerRepository(context); 32 | } 33 | 34 | return customerRepository; 35 | } 36 | } 37 | 38 | private IRepository orderRepository; 39 | public IRepository OrderRepository 40 | { 41 | get 42 | { 43 | if(orderRepository == null) 44 | { 45 | orderRepository = new OrderRepository(context); 46 | } 47 | 48 | return orderRepository; 49 | } 50 | } 51 | 52 | private IRepository productRepository; 53 | public IRepository ProductRepository 54 | { 55 | get 56 | { 57 | if (productRepository == null) 58 | { 59 | productRepository = new ProductRepository(context); 60 | } 61 | 62 | return productRepository; 63 | } 64 | } 65 | 66 | public void SaveChanges() 67 | { 68 | context.SaveChanges(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/UnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using MyShop.Infrastructure.Repositories; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | public interface IUnitOfWork 7 | { 8 | IRepository CustomerRepository { get; } 9 | IRepository OrderRepository { get; } 10 | IRepository ProductRepository { get; } 11 | 12 | void SaveChanges(); 13 | } 14 | 15 | public class UnitOfWork : IUnitOfWork 16 | { 17 | private ShoppingContext context; 18 | 19 | public UnitOfWork(ShoppingContext context) 20 | { 21 | this.context = context; 22 | } 23 | 24 | private IRepository customerRepository; 25 | public IRepository CustomerRepository 26 | { 27 | get 28 | { 29 | if (customerRepository == null) 30 | { 31 | customerRepository = new CustomerRepository(context); 32 | } 33 | 34 | return customerRepository; 35 | } 36 | } 37 | 38 | private IRepository orderRepository; 39 | public IRepository OrderRepository 40 | { 41 | get 42 | { 43 | if(orderRepository == null) 44 | { 45 | orderRepository = new OrderRepository(context); 46 | } 47 | 48 | return orderRepository; 49 | } 50 | } 51 | 52 | private IRepository productRepository; 53 | public IRepository ProductRepository 54 | { 55 | get 56 | { 57 | if (productRepository == null) 58 | { 59 | productRepository = new ProductRepository(context); 60 | } 61 | 62 | return productRepository; 63 | } 64 | } 65 | 66 | public void SaveChanges() 67 | { 68 | context.SaveChanges(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Infrastructure/UnitOfWork.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Models; 2 | using MyShop.Infrastructure.Repositories; 3 | 4 | namespace MyShop.Infrastructure 5 | { 6 | public interface IUnitOfWork 7 | { 8 | IRepository CustomerRepository { get; } 9 | IRepository OrderRepository { get; } 10 | IRepository ProductRepository { get; } 11 | 12 | void SaveChanges(); 13 | } 14 | 15 | public class UnitOfWork : IUnitOfWork 16 | { 17 | private ShoppingContext context; 18 | 19 | public UnitOfWork(ShoppingContext context) 20 | { 21 | this.context = context; 22 | } 23 | 24 | private IRepository customerRepository; 25 | public IRepository CustomerRepository 26 | { 27 | get 28 | { 29 | if (customerRepository == null) 30 | { 31 | customerRepository = new CustomerRepository(context); 32 | } 33 | 34 | return customerRepository; 35 | } 36 | } 37 | 38 | private IRepository orderRepository; 39 | public IRepository OrderRepository 40 | { 41 | get 42 | { 43 | if(orderRepository == null) 44 | { 45 | orderRepository = new OrderRepository(context); 46 | } 47 | 48 | return orderRepository; 49 | } 50 | } 51 | 52 | private IRepository productRepository; 53 | public IRepository ProductRepository 54 | { 55 | get 56 | { 57 | if (productRepository == null) 58 | { 59 | productRepository = new ProductRepository(context); 60 | } 61 | 62 | return productRepository; 63 | } 64 | } 65 | 66 | public void SaveChanges() 67 | { 68 | context.SaveChanges(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/03/Completed/MyShop.Web.Tests/OrderControllerTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using Moq; 4 | using MyShop.Domain.Models; 5 | using MyShop.Infrastructure; 6 | using MyShop.Infrastructure.Repositories; 7 | using MyShop.Web.Controllers; 8 | using MyShop.Web.Models; 9 | using System; 10 | 11 | namespace MyShop.Web.Tests 12 | { 13 | [TestClass] 14 | public class OrderControllerTests 15 | { 16 | [TestMethod] 17 | public void CanCreateOrderWithCorrectModel() 18 | { 19 | // ARRANGE 20 | var orderRepository = new Mock>(); 21 | var productRepository = new Mock>(); 22 | var customerRepository = new Mock>(); 23 | var unitOfWork = new Mock(); 24 | 25 | unitOfWork.Setup(uow => uow.CustomerRepository).Returns(() => customerRepository.Object); 26 | unitOfWork.Setup(uow => uow.OrderRepository).Returns(() => orderRepository.Object); 27 | unitOfWork.Setup(uow => uow.ProductRepository).Returns(() => productRepository.Object); 28 | 29 | var orderController = new OrderController(unitOfWork.Object); 30 | 31 | var createOrderModel = new CreateOrderModel 32 | { 33 | Customer = new CustomerModel 34 | { 35 | Name = "Filip Ekberg", 36 | ShippingAddress = "Test address", 37 | City = "Gothenburg", 38 | PostalCode = "43317", 39 | Country = "Sweden" 40 | }, 41 | LineItems = new [] 42 | { 43 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 10 }, 44 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 2 }, 45 | } 46 | }; 47 | 48 | // ACT 49 | 50 | orderController.Create(createOrderModel); 51 | 52 | // ASSERT 53 | 54 | orderRepository.Verify(r => r.Add(It.IsAny()), Times.AtLeastOnce()); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Web.Tests/OrderControllerTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using Moq; 4 | using MyShop.Domain.Models; 5 | using MyShop.Infrastructure; 6 | using MyShop.Infrastructure.Repositories; 7 | using MyShop.Web.Controllers; 8 | using MyShop.Web.Models; 9 | using System; 10 | 11 | namespace MyShop.Web.Tests 12 | { 13 | [TestClass] 14 | public class OrderControllerTests 15 | { 16 | [TestMethod] 17 | public void CanCreateOrderWithCorrectModel() 18 | { 19 | // ARRANGE 20 | var orderRepository = new Mock>(); 21 | var productRepository = new Mock>(); 22 | var customerRepository = new Mock>(); 23 | var unitOfWork = new Mock(); 24 | 25 | unitOfWork.Setup(uow => uow.CustomerRepository).Returns(() => customerRepository.Object); 26 | unitOfWork.Setup(uow => uow.OrderRepository).Returns(() => orderRepository.Object); 27 | unitOfWork.Setup(uow => uow.ProductRepository).Returns(() => productRepository.Object); 28 | 29 | var orderController = new OrderController(unitOfWork.Object); 30 | 31 | var createOrderModel = new CreateOrderModel 32 | { 33 | Customer = new CustomerModel 34 | { 35 | Name = "Filip Ekberg", 36 | ShippingAddress = "Test address", 37 | City = "Gothenburg", 38 | PostalCode = "43317", 39 | Country = "Sweden" 40 | }, 41 | LineItems = new [] 42 | { 43 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 10 }, 44 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 2 }, 45 | } 46 | }; 47 | 48 | // ACT 49 | 50 | orderController.Create(createOrderModel); 51 | 52 | // ASSERT 53 | 54 | orderRepository.Verify(r => r.Add(It.IsAny()), Times.AtLeastOnce()); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/04/Start_Here/MyShop.Web.Tests/OrderControllerTests.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Logging; 2 | using Microsoft.VisualStudio.TestTools.UnitTesting; 3 | using Moq; 4 | using MyShop.Domain.Models; 5 | using MyShop.Infrastructure; 6 | using MyShop.Infrastructure.Repositories; 7 | using MyShop.Web.Controllers; 8 | using MyShop.Web.Models; 9 | using System; 10 | 11 | namespace MyShop.Web.Tests 12 | { 13 | [TestClass] 14 | public class OrderControllerTests 15 | { 16 | [TestMethod] 17 | public void CanCreateOrderWithCorrectModel() 18 | { 19 | // ARRANGE 20 | var orderRepository = new Mock>(); 21 | var productRepository = new Mock>(); 22 | var customerRepository = new Mock>(); 23 | var unitOfWork = new Mock(); 24 | 25 | unitOfWork.Setup(uow => uow.CustomerRepository).Returns(() => customerRepository.Object); 26 | unitOfWork.Setup(uow => uow.OrderRepository).Returns(() => orderRepository.Object); 27 | unitOfWork.Setup(uow => uow.ProductRepository).Returns(() => productRepository.Object); 28 | 29 | var orderController = new OrderController(unitOfWork.Object); 30 | 31 | var createOrderModel = new CreateOrderModel 32 | { 33 | Customer = new CustomerModel 34 | { 35 | Name = "Filip Ekberg", 36 | ShippingAddress = "Test address", 37 | City = "Gothenburg", 38 | PostalCode = "43317", 39 | Country = "Sweden" 40 | }, 41 | LineItems = new [] 42 | { 43 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 10 }, 44 | new LineItemModel { ProductId = Guid.NewGuid(), Quantity = 2 }, 45 | } 46 | }; 47 | 48 | // ACT 49 | 50 | orderController.Create(createOrderModel); 51 | 52 | // ASSERT 53 | 54 | orderRepository.Verify(r => r.Add(It.IsAny()), Times.AtLeastOnce()); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30011.22 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyShop.Web", "MyShop.Web\MyShop.Web.csproj", "{304B9F8A-296B-4CBB-A684-3EBDC3A6D482}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyShop.Domain", "MyShop.Domain\MyShop.Domain.csproj", "{D1EFB329-5B5F-4F84-A6EA-468F68B73C9D}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyShop.Infrastructure", "MyShop.Infrastructure\MyShop.Infrastructure.csproj", "{2863D7D0-089D-4CEA-927B-D97272E8F9B7}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {304B9F8A-296B-4CBB-A684-3EBDC3A6D482}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {304B9F8A-296B-4CBB-A684-3EBDC3A6D482}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {304B9F8A-296B-4CBB-A684-3EBDC3A6D482}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {304B9F8A-296B-4CBB-A684-3EBDC3A6D482}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {D1EFB329-5B5F-4F84-A6EA-468F68B73C9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {D1EFB329-5B5F-4F84-A6EA-468F68B73C9D}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {D1EFB329-5B5F-4F84-A6EA-468F68B73C9D}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {D1EFB329-5B5F-4F84-A6EA-468F68B73C9D}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {2863D7D0-089D-4CEA-927B-D97272E8F9B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {2863D7D0-089D-4CEA-927B-D97272E8F9B7}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {2863D7D0-089D-4CEA-927B-D97272E8F9B7}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {2863D7D0-089D-4CEA-927B-D97272E8F9B7}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {2A0CD69B-6A42-48D3-BABD-F056A991E6F2} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Startup.cs: -------------------------------------------------------------------------------- 1 | //using Microsoft.AspNetCore.Builder; 2 | //using Microsoft.AspNetCore.Hosting; 3 | //using Microsoft.AspNetCore.Http; 4 | //using Microsoft.AspNetCore.Mvc; 5 | //using Microsoft.Extensions.Configuration; 6 | //using Microsoft.Extensions.DependencyInjection; 7 | //using MyShop.Domain.Models; 8 | //using MyShop.Infrastructure; 9 | 10 | //namespace MyShop.Web 11 | //{ 12 | // public class Startup 13 | // { 14 | // public Startup(IConfiguration configuration) 15 | // { 16 | // Configuration = configuration; 17 | // } 18 | 19 | // public IConfiguration Configuration { get; } 20 | 21 | // public void ConfigureServices(IServiceCollection services) 22 | // { 23 | // services.Configure(options => 24 | // { 25 | // // This lambda determines whether user consent for non-essential cookies is needed for a given request. 26 | // options.CheckConsentNeeded = context => true; 27 | // options.MinimumSameSitePolicy = SameSiteMode.None; 28 | // }); 29 | 30 | // services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); 31 | 32 | 33 | // services.AddTransient(); 34 | 35 | // } 36 | 37 | // // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 38 | // public void Configure(IApplicationBuilder app, IHostingEnvironment env) 39 | // { 40 | // if (env.IsDevelopment()) 41 | // { 42 | // app.UseDeveloperExceptionPage(); 43 | // } 44 | // else 45 | // { 46 | // app.UseExceptionHandler("/Order/Error"); 47 | // app.UseHsts(); 48 | // } 49 | 50 | // app.UseHttpsRedirection(); 51 | // app.UseStaticFiles(); 52 | // app.UseCookiePolicy(); 53 | 54 | // app.UseMvc(routes => 55 | // { 56 | // routes.MapRoute( 57 | // name: "default", 58 | // template: "{controller=Order}/{action=Index}/{id?}"); 59 | // }); 60 | // } 61 | // } 62 | //} 63 | -------------------------------------------------------------------------------- /src/04/Completed/MyShop.Infrastructure/Repositories/CustomerRepository.cs: -------------------------------------------------------------------------------- 1 | using MyShop.Domain.Lazy; 2 | using MyShop.Domain.Models; 3 | using MyShop.Infrastructure.Lazy.Ghosts; 4 | using MyShop.Infrastructure.Lazy.Proxies; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | 9 | namespace MyShop.Infrastructure.Repositories 10 | { 11 | public class CustomerRepository : GenericRepository 12 | { 13 | public CustomerRepository(ShoppingContext context) : base(context) 14 | { 15 | } 16 | 17 | public override Customer Get(Guid id) 18 | { 19 | var customerId = context.Customers 20 | .Where(c => c.CustomerId == id) 21 | .Select(c => c.CustomerId) 22 | .Single(); 23 | 24 | return new GhostCustomer(() => base.Get(id)) 25 | { 26 | CustomerId = customerId 27 | }; 28 | } 29 | 30 | public override IEnumerable All() 31 | { 32 | // Lazy Loading: Value Holder 33 | //ProfilePictureValueHolder = new ValueHolder(); 34 | //ProfilePictureValueHolder = new Lazy(() => 35 | //{ 36 | // return ProfilePictureService.GetFor(customer.Name); 37 | //}); 38 | 39 | return base.All().Select(MapToProxy); 40 | } 41 | 42 | public override Customer Update(Customer entity) 43 | { 44 | var customer = context.Customers 45 | .Single(c => c.CustomerId == entity.CustomerId); 46 | 47 | customer.Name = entity.Name; 48 | customer.City = entity.City; 49 | customer.PostalCode = entity.PostalCode; 50 | customer.ShippingAddress = entity.ShippingAddress; 51 | customer.Country = entity.Country; 52 | 53 | return base.Update(customer); 54 | } 55 | 56 | private CustomerProxy MapToProxy(Customer customer) 57 | { 58 | return new CustomerProxy 59 | { 60 | CustomerId = customer.CustomerId, 61 | Name = customer.Name, 62 | ShippingAddress = customer.ShippingAddress, 63 | City = customer.City, 64 | PostalCode = customer.PostalCode, 65 | Country = customer.Country 66 | }; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/02/Start_Here/MyShop.Web/Controllers/OrderController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.EntityFrameworkCore; 6 | using MyShop.Domain.Models; 7 | using MyShop.Infrastructure; 8 | using MyShop.Web.Models; 9 | 10 | namespace MyShop.Web.Controllers 11 | { 12 | public class OrderController : Controller 13 | { 14 | private ShoppingContext context; 15 | 16 | public OrderController() 17 | { 18 | context = new ShoppingContext(); 19 | } 20 | 21 | public IActionResult Index() 22 | { 23 | var orders = context.Orders 24 | .Include(order => order.LineItems) 25 | .ThenInclude(lineItem => lineItem.Product) 26 | .Where(order => order.OrderDate > DateTime.UtcNow.AddDays(-1)).ToList(); 27 | 28 | return View(orders); 29 | } 30 | 31 | public IActionResult Create() 32 | { 33 | var products = context.Products.ToList(); 34 | 35 | return View(products); 36 | } 37 | 38 | [HttpPost] 39 | public IActionResult Create(CreateOrderModel model) 40 | { 41 | if (!model.LineItems.Any()) return BadRequest("Please submit line items"); 42 | 43 | if (string.IsNullOrWhiteSpace(model.Customer.Name)) return BadRequest("Customer needs a name"); 44 | 45 | var customer = new Customer 46 | { 47 | Name = model.Customer.Name, 48 | ShippingAddress = model.Customer.ShippingAddress, 49 | City = model.Customer.City, 50 | PostalCode = model.Customer.PostalCode, 51 | Country = model.Customer.Country 52 | }; 53 | 54 | var order = new Order 55 | { 56 | LineItems = model.LineItems 57 | .Select(line => new LineItem { ProductId = line.ProductId, Quantity = line.Quantity }) 58 | .ToList(), 59 | 60 | Customer = customer 61 | }; 62 | 63 | context.Orders.Add(order); 64 | 65 | context.SaveChanges(); 66 | 67 | return Ok("Order Created"); 68 | } 69 | 70 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 71 | public IActionResult Error() 72 | { 73 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/02/Completed/MyShop.Web/Controllers/OrderController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.Linq; 4 | using Microsoft.AspNetCore.Mvc; 5 | using MyShop.Domain.Models; 6 | using MyShop.Infrastructure.Repositories; 7 | using MyShop.Web.Models; 8 | 9 | namespace MyShop.Web.Controllers 10 | { 11 | public class OrderController : Controller 12 | { 13 | private readonly IRepository orderRepository; 14 | private readonly IRepository productRepository; 15 | 16 | public OrderController(IRepository orderRepository, 17 | IRepository productRepository) 18 | { 19 | this.orderRepository = orderRepository; 20 | this.productRepository = productRepository; 21 | } 22 | 23 | public IActionResult Index() 24 | { 25 | var orders = orderRepository.Find(order => order.OrderDate > DateTime.UtcNow.AddDays(-1)); 26 | 27 | return View(orders); 28 | } 29 | 30 | public IActionResult Create() 31 | { 32 | var products = productRepository.All(); 33 | 34 | return View(products); 35 | } 36 | 37 | [HttpPost] 38 | public IActionResult Create(CreateOrderModel model) 39 | { 40 | if (!model.LineItems.Any()) return BadRequest("Please submit line items"); 41 | 42 | if (string.IsNullOrWhiteSpace(model.Customer.Name)) return BadRequest("Customer needs a name"); 43 | 44 | var customer = new Customer 45 | { 46 | Name = model.Customer.Name, 47 | ShippingAddress = model.Customer.ShippingAddress, 48 | City = model.Customer.City, 49 | PostalCode = model.Customer.PostalCode, 50 | Country = model.Customer.Country 51 | }; 52 | 53 | var order = new Order 54 | { 55 | LineItems = model.LineItems 56 | .Select(line => new LineItem { ProductId = line.ProductId, Quantity = line.Quantity }) 57 | .ToList(), 58 | 59 | Customer = customer 60 | }; 61 | 62 | orderRepository.Add(order); 63 | 64 | orderRepository.SaveChanges(); 65 | 66 | return Ok("Order Created"); 67 | } 68 | 69 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 70 | public IActionResult Error() 71 | { 72 | return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); 73 | } 74 | } 75 | } 76 | --------------------------------------------------------------------------------