diff --git a/eShopOnContainers.sln b/eShopOnContainers.sln index 883ded9bc..7d03f4822 100644 --- a/eShopOnContainers.sln +++ b/eShopOnContainers.sln @@ -32,18 +32,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.API", "src\Service EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.Domain", "src\Services\Ordering\Ordering.Domain\Ordering.Domain.xproj", "{F5598DCB-6DDE-4661-AD9D-A55612DA7E76}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.SqlData", "src\Services\Ordering\Ordering.SqlData\Ordering.SqlData.xproj", "{5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A857AD10-40FF-4303-BEC2-FF1C58D5735E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{EF0337F2-ED00-4643-89FD-EE10863F1870}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.Test", "test\Services\Ordering.Test\Ordering.Test.xproj", "{A0AFC432-3846-4B4E-BD8E-3C8C896F4967}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Console App", "Console App", "{48FC45C5-223F-4B59-AC77-6CBB1C561E85}" -EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "eShopConsole", "src\Console\eShopConsole\eShopConsole.xproj", "{C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "eShopOnContainers.WebMVC", "src\Web\WebMVC\eShopOnContainers.WebMVC.xproj", "{F0333D8E-0B27-42B7-B2C6-78F3657624E2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.Core", "src\Mobile\eShopOnContainers\eShopOnContainers.Core\eShopOnContainers.Core.csproj", "{65116D1C-145B-4693-ABDA-F0FB6F425191}" @@ -69,6 +63,9 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.TestRunner.Windows", "src\Mobile\eShopOnContainers\eShopOnContainers.TestRunner.Windows\eShopOnContainers.TestRunner.Windows.csproj", "{02680C26-CA1D-4D9D-A7E3-D66AF5BE6F2F}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "eShopOnContainers.TestRunner.iOS", "src\Mobile\eShopOnContainers\eShopOnContainers.TestRunner.iOS\eShopOnContainers.TestRunner.iOS.csproj", "{B68C2B56-7581-46AE-B55D-D25DDFD3BFE3}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.Application", "src\Services\Ordering\Ordering.Application\Ordering.Application.xproj", "{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ordering.Infrastructure", "src\Services\Ordering\Ordering.Infrastructure\Ordering.Infrastructure.xproj", "{95F1F07C-4D92-4742-BD07-E5B805AAB651}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -202,32 +199,6 @@ Global {F5598DCB-6DDE-4661-AD9D-A55612DA7E76}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {F5598DCB-6DDE-4661-AD9D-A55612DA7E76}.Release|x64.ActiveCfg = Release|Any CPU {F5598DCB-6DDE-4661-AD9D-A55612DA7E76}.Release|x86.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Ad-Hoc|x64.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.AppStore|Any CPU.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.AppStore|ARM.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.AppStore|iPhone.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.AppStore|x64.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.AppStore|x86.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Debug|ARM.ActiveCfg = Debug|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Debug|x64.ActiveCfg = Debug|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Debug|x86.ActiveCfg = Debug|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Release|Any CPU.Build.0 = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Release|ARM.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Release|iPhone.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Release|x64.ActiveCfg = Release|Any CPU - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Release|x86.ActiveCfg = Release|Any CPU {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU @@ -254,32 +225,6 @@ Global {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Release|x64.ActiveCfg = Release|Any CPU {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Release|x86.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Ad-Hoc|x64.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Ad-Hoc|x86.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.AppStore|Any CPU.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.AppStore|ARM.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.AppStore|iPhone.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.AppStore|x64.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.AppStore|x86.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Debug|ARM.ActiveCfg = Debug|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Debug|x64.ActiveCfg = Debug|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Debug|x86.ActiveCfg = Debug|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Release|Any CPU.Build.0 = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Release|ARM.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Release|iPhone.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Release|x64.ActiveCfg = Release|Any CPU - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7}.Release|x86.ActiveCfg = Release|Any CPU {F0333D8E-0B27-42B7-B2C6-78F3657624E2}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU {F0333D8E-0B27-42B7-B2C6-78F3657624E2}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU {F0333D8E-0B27-42B7-B2C6-78F3657624E2}.Ad-Hoc|iPhone.ActiveCfg = Release|Any CPU @@ -568,6 +513,7 @@ Global {9842DB3A-1391-48C7-A49C-2FABD0A18AC2}.Release|x64.Build.0 = Release|Any CPU {9842DB3A-1391-48C7-A49C-2FABD0A18AC2}.Release|x86.ActiveCfg = Release|Any CPU {9842DB3A-1391-48C7-A49C-2FABD0A18AC2}.Release|x86.Build.0 = Release|Any CPU +<<<<<<< HEAD {F7B6A162-BC4D-4924-B16A-713F9B0344E7}.Ad-Hoc|Any CPU.ActiveCfg = Release|Any CPU {F7B6A162-BC4D-4924-B16A-713F9B0344E7}.Ad-Hoc|Any CPU.Build.0 = Release|Any CPU {F7B6A162-BC4D-4924-B16A-713F9B0344E7}.Ad-Hoc|ARM.ActiveCfg = Release|Any CPU @@ -782,6 +728,104 @@ Global {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3}.Release|x64.ActiveCfg = Release|iPhone {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3}.Release|x86.ActiveCfg = Release|iPhone +======= + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|ARM.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhone.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x64.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x64.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x86.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.AppStore|x86.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|ARM.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|ARM.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhone.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x64.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x64.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x86.ActiveCfg = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Debug|x86.Build.0 = Debug|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|Any CPU.Build.0 = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|ARM.ActiveCfg = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|ARM.Build.0 = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhone.ActiveCfg = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhone.Build.0 = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x64.ActiveCfg = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x64.Build.0 = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x86.ActiveCfg = Release|Any CPU + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7}.Release|x86.Build.0 = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|x64.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Ad-Hoc|x86.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|Any CPU.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|ARM.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|ARM.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|iPhone.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|iPhone.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|x64.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|x64.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|x86.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.AppStore|x86.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|ARM.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|ARM.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|iPhone.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|x64.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|x64.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|x86.ActiveCfg = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Debug|x86.Build.0 = Debug|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|Any CPU.Build.0 = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|ARM.ActiveCfg = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|ARM.Build.0 = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|iPhone.ActiveCfg = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|iPhone.Build.0 = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|x64.ActiveCfg = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|x64.Build.0 = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|x86.ActiveCfg = Release|Any CPU + {95F1F07C-4D92-4742-BD07-E5B805AAB651}.Release|x86.Build.0 = Release|Any CPU +>>>>>>> OrderingRefactoring EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -797,11 +841,8 @@ Global {42681D9D-750A-4DF7-BD9F-9292CFD5C253} = {326A7FB3-5295-468C-A4FE-67DCB823E1E5} {231226CE-690B-4979-8870-9A79D80928E2} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B} {F5598DCB-6DDE-4661-AD9D-A55612DA7E76} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B} - {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B} {EF0337F2-ED00-4643-89FD-EE10863F1870} = {A857AD10-40FF-4303-BEC2-FF1C58D5735E} {A0AFC432-3846-4B4E-BD8E-3C8C896F4967} = {EF0337F2-ED00-4643-89FD-EE10863F1870} - {48FC45C5-223F-4B59-AC77-6CBB1C561E85} = {932D8224-11F6-4D07-B109-DA28AD288A63} - {C10C7B69-CE4F-4167-928E-33B7FA1DFFC7} = {48FC45C5-223F-4B59-AC77-6CBB1C561E85} {F0333D8E-0B27-42B7-B2C6-78F3657624E2} = {E279BF0F-7F66-4F3A-A3AB-2CDA66C1CD04} {65116D1C-145B-4693-ABDA-F0FB6F425191} = {778289CA-31F7-4464-8C2A-612EE846F8A7} {62DBB163-9CA9-4818-B48B-13233DF37C24} = {9CC7814B-72A6-465B-A61C-57B512DEE303} @@ -810,10 +851,15 @@ Global {778289CA-31F7-4464-8C2A-612EE846F8A7} = {F61357CE-1CC2-410E-8776-B16EEBC98EB8} {9CC7814B-72A6-465B-A61C-57B512DEE303} = {F61357CE-1CC2-410E-8776-B16EEBC98EB8} {9842DB3A-1391-48C7-A49C-2FABD0A18AC2} = {E279BF0F-7F66-4F3A-A3AB-2CDA66C1CD04} +<<<<<<< HEAD {B7B1D395-4E06-4036-BE86-C216756B9367} = {A857AD10-40FF-4303-BEC2-FF1C58D5735E} {F7B6A162-BC4D-4924-B16A-713F9B0344E7} = {B7B1D395-4E06-4036-BE86-C216756B9367} {A289A7F0-ACD8-42AE-87B6-AB1AFD310BF1} = {B7B1D395-4E06-4036-BE86-C216756B9367} {02680C26-CA1D-4D9D-A7E3-D66AF5BE6F2F} = {B7B1D395-4E06-4036-BE86-C216756B9367} {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} = {B7B1D395-4E06-4036-BE86-C216756B9367} +======= + {4193CAA3-A1C3-4818-A06F-A2D85FDE77E7} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B} + {95F1F07C-4D92-4742-BD07-E5B805AAB651} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B} +>>>>>>> OrderingRefactoring EndGlobalSection EndGlobal diff --git a/global.json b/global.json index bf6ec0487..c5112dcd4 100644 --- a/global.json +++ b/global.json @@ -7,6 +7,6 @@ ], "sdk": { - "version": "1.0.0-preview2-003121" + "version": "1.0.0-preview2-003131" } } diff --git a/src/Console/eShopConsole/Program.cs b/src/Console/eShopConsole/Program.cs index 7a97661a0..f647bc2d5 100644 --- a/src/Console/eShopConsole/Program.cs +++ b/src/Console/eShopConsole/Program.cs @@ -12,60 +12,60 @@ namespace eShopConsole { public static void Main(string[] args) { - // All contexts that share the same service provider will share the same database + //// All contexts that share the same service provider will share the same database - //Using InMemory DB - //var options = DbContextUtil.CreateNewContextOptionsForInMemoryDB(); + ////Using InMemory DB + ////var options = DbContextUtil.CreateNewContextOptionsForInMemoryDB(); - //Using Sql Server - var options = DbContextUtil.CreateNewContextOptionsForSqlDb(); + ////Using Sql Server + //var options = DbContextUtil.CreateNewContextOptionsForSqlDb(); - // Run the test against one instance of the context - using (var context = new OrderingDbContext(options)) - { - IOrderRepository orderRepository = new OrderRepository(context); + //// Run the test against one instance of the context + //using (var context = new OrderingDbContext(options)) + //{ + // IOrderRepository orderRepository = new OrderRepository(context); - //Create generic Address ValueObject - Address sampleAddress = new Address("15703 NE 61st Ct.", - "Redmond", - "Washington", - "WA", - "United States", - "US", - "98052", - 47.661492, - -122.131309 - ); - //Create sample Orders - Order order1 = new Order(Guid.NewGuid(), sampleAddress, sampleAddress); + // //Create generic Address ValueObject + // Address sampleAddress = new Address("15703 NE 61st Ct.", + // "Redmond", + // "Washington", + // "WA", + // "United States", + // "US", + // "98052", + // 47.661492, + // -122.131309 + // ); + // //Create sample Orders + // Order order1 = new Order(Guid.NewGuid(), sampleAddress, sampleAddress); - //Add a few OrderItems - order1.AddNewOrderItem(Guid.NewGuid(), 2, 25, 30); - order1.AddNewOrderItem(Guid.NewGuid(), 1, 58, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 1, 60, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 3, 12, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 5, 3, 0); + // //Add a few OrderItems + // order1.AddNewOrderItem(Guid.NewGuid(), 2, 25, 30); + // order1.AddNewOrderItem(Guid.NewGuid(), 1, 58, 0); + // order1.AddNewOrderItem(Guid.NewGuid(), 1, 60, 0); + // order1.AddNewOrderItem(Guid.NewGuid(), 3, 12, 0); + // order1.AddNewOrderItem(Guid.NewGuid(), 5, 3, 0); - orderRepository.Add(order1); - orderRepository.UnitOfWork.CommitAsync(); + // orderRepository.Add(order1); + // orderRepository.UnitOfWork.CommitAsync(); - //With no Async Repository - //context.Orders.Add(order1); - //context.SaveChanges(); + // //With no Async Repository + // //context.Orders.Add(order1); + // //context.SaveChanges(); - } + //} - //// Use a separate instance of the context to verify correct data was saved to database - using (var context = new OrderingDbContext(options)) - { - var orders = context.Orders - .Include(o => o.ShippingAddress) - .Include(o => o.BillingAddress) - .ToList(); + ////// Use a separate instance of the context to verify correct data was saved to database + //using (var context = new OrderingDbContext(options)) + //{ + // var orders = context.Orders + // .Include(o => o.ShippingAddress) + // .Include(o => o.BillingAddress) + // .ToList(); - string cityName = orders.First().ShippingAddress.City; - Console.WriteLine("City name retreived from SQL Server: "+cityName); - } + // string cityName = orders.First().ShippingAddress.City; + // Console.WriteLine("City name retreived from SQL Server: "+cityName); + //} } } } diff --git a/src/Console/eShopConsole/project.json b/src/Console/eShopConsole/project.json index 1b299277a..f953c60fe 100644 --- a/src/Console/eShopConsole/project.json +++ b/src/Console/eShopConsole/project.json @@ -10,9 +10,7 @@ "type": "platform", "version": "1.0.0" }, - "Ordering.API": "1.0.0-*", "Ordering.Domain": "1.0.0-*", - "Ordering.SqlData": "1.0.0-*" }, "frameworks": { "netcoreapp1.0": { diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj index 2f6e003b9..003a04a26 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj @@ -17,7 +17,7 @@ Off Properties\AndroidManifest.xml true - v7.0 + v6.0 armeabi,armeabi-v7a,x86 diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj.bak b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj.bak index cb65dfd5f..dcd1de431 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj.bak +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.Droid/eShopOnContainers.Droid.csproj.bak @@ -17,7 +17,7 @@ Off Properties\AndroidManifest.xml true - v6.0 + v7.0 armeabi,armeabi-v7a,x86 @@ -93,6 +93,7 @@ ..\..\packages\Xamarin.Forms.2.3.2.127\lib\MonoAndroid10\FormsViewGroup.dll True + ..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll True @@ -107,8 +108,8 @@ - - ..\..\packages\Newtonsoft.Json.8.0.3\lib\portable-net40+sl5+wp80+win8+wpa81\Newtonsoft.Json.dll + + ..\..\packages\Newtonsoft.Json.9.0.2-beta1\lib\netstandard1.1\Newtonsoft.Json.dll True @@ -203,7 +204,6 @@ - @@ -300,34 +300,52 @@ - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj index bb833177e..545e3dbfb 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj @@ -16,7 +16,7 @@ Resources\Resource.Designer.cs Off True - v7.0 + v6.0 Properties\AndroidManifest.xml diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj.bak b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj.bak new file mode 100644 index 000000000..bb833177e --- /dev/null +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.Droid/eShopOnContainers.TestRunner.Droid.csproj.bak @@ -0,0 +1,184 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {A289A7F0-ACD8-42AE-87B6-AB1AFD310BF1} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + eShopOnContainers.TestRunner.Droid + eShopOnContainers.TestRunner.Droid + 512 + true + Resources\Resource.Designer.cs + Off + True + v7.0 + Properties\AndroidManifest.xml + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + True + None + + + pdbonly + true + true + true + bin\Release\ + TRACE + prompt + 4 + False + SdkOnly + + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\MonoAndroid10\FormsViewGroup.dll + True + + + + + + + + + ..\..\packages\Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Animated.Vector.Drawable.dll + True + + + ..\..\packages\Xamarin.Android.Support.Design.23.3.0\lib\MonoAndroid43\Xamarin.Android.Support.Design.dll + True + + + ..\..\packages\Xamarin.Android.Support.v4.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll + True + + + ..\..\packages\Xamarin.Android.Support.v7.AppCompat.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll + True + + + ..\..\packages\Xamarin.Android.Support.v7.CardView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.CardView.dll + True + + + ..\..\packages\Xamarin.Android.Support.v7.MediaRouter.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll + True + + + ..\..\packages\Xamarin.Android.Support.v7.RecyclerView.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v7.RecyclerView.dll + True + + + ..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Vector.Drawable.dll + True + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\MonoAndroid10\Xamarin.Forms.Core.dll + True + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\MonoAndroid10\Xamarin.Forms.Platform.dll + True + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll + True + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll + True + + + ..\..\packages\xunit.abstractions.2.0.1\lib\netstandard1.0\xunit.abstractions.dll + True + + + ..\..\packages\xunit.assert.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.assert.dll + True + + + ..\..\packages\xunit.extensibility.core.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.core.dll + True + + + ..\..\packages\xunit.extensibility.execution.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.execution.dotnet.dll + True + + + ..\..\packages\xunit.runner.devices.2.1.0\lib\MonoAndroid\xunit.runner.devices.dll + True + + + ..\..\packages\xunit.runner.utility.2.2.0-beta4-build3444\lib\netstandard1.1\xunit.runner.utility.dotnet.dll + True + + + + + + + + + + + + + + + + Designer + + + + + + + + + + + + + + + + + {f7b6a162-bc4d-4924-b16a-713f9b0344e7} + eShopOnContainers.UnitTests + + + + + + + Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}. + + + + + + + + + \ No newline at end of file diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj index 0d45fd280..dee8a86f4 100644 --- a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj @@ -8,7 +8,7 @@ Exe eShopOnContainers.TestRunner.iOS Resources - eShopOnContainers.TestRunner.iOS + eShopOnContainersTestRunneriOS diff --git a/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj.bak b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj.bak new file mode 100644 index 000000000..0d45fd280 --- /dev/null +++ b/src/Mobile/eShopOnContainers/eShopOnContainers.TestRunner.iOS/eShopOnContainers.TestRunner.iOS.csproj.bak @@ -0,0 +1,175 @@ + + + + Debug + iPhoneSimulator + {B68C2B56-7581-46AE-B55D-D25DDFD3BFE3} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + eShopOnContainers.TestRunner.iOS + Resources + eShopOnContainers.TestRunner.iOS + + + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + x86_64 + SdkOnly + True + 10.1 + False + False + False + False + False + False + False + True + Default + HttpClientHandler + False + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + None + x86_64 + false + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + ARMv7, ARM64 + Entitlements.plist + iPhone Developer + true + + + none + true + bin\iPhone\Release + prompt + 4 + Entitlements.plist + ARMv7, ARM64 + false + iPhone Developer + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + ARMv7, ARM64 + Entitlements.plist + True + Automatic:AdHoc + iPhone Distribution + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + ARMv7, ARM64 + Entitlements.plist + Automatic:AppStore + iPhone Distribution + + + + + + + + + + + + + + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\Xamarin.iOS10\Xamarin.Forms.Core.dll + True + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\Xamarin.iOS10\Xamarin.Forms.Platform.dll + True + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\Xamarin.iOS10\Xamarin.Forms.Platform.iOS.dll + True + + + ..\..\packages\Xamarin.Forms.2.3.3.166-pre4\lib\Xamarin.iOS10\Xamarin.Forms.Xaml.dll + True + + + + ..\..\packages\xunit.abstractions.2.0.1\lib\netstandard1.0\xunit.abstractions.dll + True + + + ..\..\packages\xunit.assert.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.assert.dll + True + + + ..\..\packages\xunit.extensibility.core.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.core.dll + True + + + ..\..\packages\xunit.extensibility.execution.2.2.0-beta4-build3444\lib\netstandard1.0\xunit.execution.dotnet.dll + True + + + ..\..\packages\xunit.runner.devices.2.1.0\lib\Xamarin.iOS\xunit.runner.devices.dll + True + + + ..\..\packages\xunit.runner.utility.2.2.0-beta4-build3444\lib\netstandard1.1\xunit.runner.utility.dotnet.dll + True + + + + + + + + + {f7b6a162-bc4d-4924-b16a-713f9b0344e7} + eShopOnContainers.UnitTests + + + + + + + Este proyecto hace referencia a los paquetes NuGet que faltan en este equipo. Use la restauración de paquetes NuGet para descargarlos. Para obtener más información, consulte http://go.microsoft.com/fwlink/?LinkID=322105. El archivo que falta es {0}. + + + + + + \ No newline at end of file diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 8815a6843..1507cf408 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -18,8 +18,14 @@ var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile($"settings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true) - .AddEnvironmentVariables(); + .AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true); + + if (env.IsDevelopment()) + { + builder.AddUserSecrets(); + } + + builder.AddEnvironmentVariables(); Configuration = builder.Build(); } diff --git a/src/Services/Catalog/Catalog.API/project.json b/src/Services/Catalog/Catalog.API/project.json index 813301bd7..8297fb35b 100644 --- a/src/Services/Catalog/Catalog.API/project.json +++ b/src/Services/Catalog/Catalog.API/project.json @@ -10,6 +10,7 @@ "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", + "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Logging": "1.0.0", "Microsoft.Extensions.Logging.Console": "1.0.0", @@ -53,5 +54,6 @@ "Dockerfile" ] }, - "scripts": {} + "scripts": {}, + "userSecretsId": "aspnet-Catalog.API-20161122013618" } \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/.vscode/launch.json b/src/Services/Ordering/Ordering.API/.vscode/launch.json deleted file mode 100644 index b311e1323..000000000 --- a/src/Services/Ordering/Ordering.API/.vscode/launch.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (web)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceRoot}\\bin\\Debug\\netcoreapp1.0\\Ordering.API.dll", - "args": [], - "cwd": "${workspaceRoot}", - "stopAtEntry": false, - "launchBrowser": { - "enabled": true, - "args": "${auto-detect-url}", - "windows": { - "command": "cmd.exe", - "args": "/C start ${auto-detect-url}" - }, - "osx": { - "command": "open" - }, - "linux": { - "command": "xdg-open" - } - }, - "env": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "sourceFileMap": { - "/Views": "${workspaceRoot}/Views" - } - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command.pickProcess}" - } - ] -} \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/.vscode/tasks.json b/src/Services/Ordering/Ordering.API/.vscode/tasks.json deleted file mode 100644 index 9cd37c150..000000000 --- a/src/Services/Ordering/Ordering.API/.vscode/tasks.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "0.1.0", - "command": "dotnet", - "isShellCommand": true, - "args": [], - "tasks": [ - { - "taskName": "build", - "args": [ - "${workspaceRoot}\\project.json" - ], - "isBuildCommand": true, - "problemMatcher": "$msCompile" - } - ] -} \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Controllers/EnvironmentInfoController.cs b/src/Services/Ordering/Ordering.API/Controllers/EnvironmentInfoController.cs deleted file mode 100644 index ba4d56509..000000000 --- a/src/Services/Ordering/Ordering.API/Controllers/EnvironmentInfoController.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; - -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers -{ - [Route("api/[controller]")] - public class EnvironmentInfoController : Controller - { - // GET api/environmentInfo/machinename - [HttpGet("machinename")] - public dynamic GetMachineName() - { - return new - { - InstanceName = Environment.MachineName - }; - } - - } -} \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/Controllers/OrderingController.cs b/src/Services/Ordering/Ordering.API/Controllers/OrderingController.cs deleted file mode 100644 index 6b9c4b2f2..000000000 --- a/src/Services/Ordering/Ordering.API/Controllers/OrderingController.cs +++ /dev/null @@ -1,129 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; - -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; -using Microsoft.EntityFrameworkCore; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries; - -namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers -{ - [Route("api/[controller]")] - public class OrderingController : Controller - { - private IOrderRepository _orderRepository; - private IOrderdingQueries _queries; - - //private OrderingDbContext _context; - - public OrderingController(IOrderRepository orderRepository, - IOrderdingQueries orderingQueries //, - //OrderingDbContext context - ) - { - //Injected objects from the IoC container - _orderRepository = orderRepository; - _queries = orderingQueries; - //_context = context; - } - - - // GET api/ordering/orders - [HttpGet("orders")] - public async Task GetAllOrders() - { - dynamic response = await _queries.GetAllOrdersIncludingValueObjectsAndChildEntities(); - return Ok(response); - } - - - // GET api/ordering/orders/xxxGUIDxxxx - [HttpGet("orders/{orderId:Guid}")] - public async Task GetOrderById(Guid orderId) - { - dynamic response = await _queries.GetOrderById(orderId); - return Ok(response); - } - - //(CDLTLL) - Using parameters - //Alternate method if using several parameters instead of part of the URL - // GET api/ordering/orders/?orderId=xxxGUIDxxx&otherParam=value - //[HttpGet("orders")] - //public Order GetOrderByGuid([FromUri] Guid orderId, [FromUri] string otherParam) - - - // POST api/ordering/orders/create - [HttpPut("orders/create")] - public async Task Post([FromBody]Order order) - { - _orderRepository.Add(order); - int numChanges = await _orderRepository.UnitOfWork.CommitAsync(); - return Ok(numChanges); - } - - // PUT api/ordering/orders/xxxOrderGUIDxxxx/update - [HttpPut("orders/{orderId:Guid}/update")] - public async Task UpdateOrder(Guid orderID, [FromBody] Order orderToUpdate) - { - _orderRepository.Update(orderToUpdate); - int numChanges = await _orderRepository.UnitOfWork.CommitAsync(); - return Ok(numChanges); - } - - // DELETE api/ordering/orders/xxxOrderGUIDxxxx - [HttpDelete("orders/{orderId:Guid}/remove")] - public async Task Remove(Guid id) - { - await _orderRepository.Remove(id); - int numChanges = await _orderRepository.UnitOfWork.CommitAsync(); - return Ok(numChanges); - } - - - // GET api/ordering/orders/add_test_data_and_get_all - [HttpGet("orders/add_test_data_and_get_all")] - public async Task AddTestDataAndGetAllOrders() - { - //TEST ADDING ORDERS ********************************* - //Create generic Address ValueObject - Address sampleAddress = new Address("15703 NE 61st Ct.", - "Redmond", - "Washington", - "WA", - "United States", - "US", - "98052", - 47.661492, - -122.131309 - ); - //Create sample Orders - Order order1 = new Order(Guid.NewGuid(), sampleAddress, sampleAddress); - - //Add a few OrderItems - order1.AddNewOrderItem(Guid.NewGuid(), 2, 25, 30); - order1.AddNewOrderItem(Guid.NewGuid(), 1, 58, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 1, 60, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 3, 12, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 5, 3, 0); - - _orderRepository.Add(order1); - int numRecs = await _orderRepository.UnitOfWork.CommitAsync(); - - //_context.Orders.Add(order1); - //_context.SaveChanges(); - - //***************************************************** - - dynamic response = await _queries.GetAllOrdersIncludingValueObjectsAndChildEntities(); - return Ok(response); - } - - } - -} - - diff --git a/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs b/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs new file mode 100644 index 000000000..02d209ad0 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs @@ -0,0 +1,98 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers +{ + using Application.Commands; + using Application.Queries; + using MediatR; + using Microsoft.AspNetCore.Mvc; + using Models; + using System; + using System.Threading.Tasks; + + [Route("api/v1/[controller]")] + public class OrdersController : Controller + { + private readonly IMediator _mediator; + private readonly IOrderQueries _orderQueries; + + public OrdersController(IMediator mediator, IOrderQueries orderQueries) + { + if (mediator == null) + { + throw new ArgumentNullException(nameof(mediator)); + } + + if (orderQueries == null) + { + throw new ArgumentNullException(nameof(orderQueries)); + } + + _mediator = mediator; + _orderQueries = orderQueries; + } + + [Route("new")] + [HttpPost] + public async Task AddOrder([FromBody]NewOrderViewModel order) + { + var newOrderRequest = new NewOrderRequest() + { + Buyer =GetUserName(), //TODO + CardTypeId = 1, //TODO + CardHolderName = order.CardHolderName, + CardNumber = order.CardNumber, + CardExpiration = order.CardExpiration, + CardSecurityNumber = order.CardSecurityNumber, + State = order.ShippingState, + City = order.ShippingCity, + Country = order.ShippingCountry, + Street = order.ShippingStreet + }; + + var added = await _mediator.SendAsync(newOrderRequest); + + if (added) + { + return Ok(); + } + + return BadRequest(); + } + + [Route("{orderId:int}")] + [HttpGet] + public async Task GetOrder(int orderId) + { + var order = await _orderQueries.GetOrder(orderId); + + + return Ok(order); + } + + [Route("")] + [HttpGet] + public async Task GetOrders() + { + var orders = await _orderQueries.GetOrders(); + + + return Ok(orders); + } + + [Route("cardtypes")] + [HttpGet] + public async Task GetCardTypes() + { + var cardTypes = await _orderQueries.GetCardTypes(); + + return Ok(cardTypes); + } + + string GetUserName() + { + return "MOCK"; + } + } + +} + + diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs b/src/Services/Ordering/Ordering.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs new file mode 100644 index 000000000..55cb33c99 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/ActionResults/InternalServerErrorObjectResult.cs @@ -0,0 +1,14 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.ActionResults +{ + using AspNetCore.Http; + using Microsoft.AspNetCore.Mvc; + + public class InternalServerErrorObjectResult : ObjectResult + { + public InternalServerErrorObjectResult(object error) + : base(error) + { + StatusCode = StatusCodes.Status500InternalServerError; + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs new file mode 100644 index 000000000..2c159c4b3 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/ApplicationModule.cs @@ -0,0 +1,28 @@ + + +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules +{ + using Application.Queries; + using Autofac; + using Domain.Repositories; + using Ordering.Infrastructure.Repositories; + + public class ApplicationModule + :Autofac.Module + { + protected override void Load(ContainerBuilder builder) + { + builder.RegisterType() + .As() + .InstancePerLifetimeScope(); + + builder.RegisterType() + .As() + .InstancePerLifetimeScope(); + + builder.RegisterType() + .As() + .InstancePerLifetimeScope(); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs new file mode 100644 index 000000000..36427aefd --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/AutofacModules/MediatorModule.cs @@ -0,0 +1,43 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.AutofacModules +{ + using Application.Commands; + using Application.Decorators; + using Autofac; + using Autofac.Core; + using MediatR; + using System.Collections.Generic; + using System.Linq; + using System.Reflection; + + public class MediatorModule : Autofac.Module + { + protected override void Load(ContainerBuilder builder) + { + builder.RegisterAssemblyTypes(typeof(IMediator).GetTypeInfo().Assembly) + .AsImplementedInterfaces(); + + builder.RegisterAssemblyTypes(typeof(NewOrderRequest).GetTypeInfo().Assembly) + .As(o => o.GetInterfaces() + .Where(i => i.IsClosedTypeOf(typeof(IAsyncRequestHandler<,>))) + .Select(i => new KeyedService("IAsyncRequestHandler", i))); + + builder.Register(context => + { + var componentContext = context.Resolve(); + + return t => componentContext.Resolve(t); + }); + + builder.Register(context => + { + var componentContext = context.Resolve(); + + return t => (IEnumerable)componentContext.Resolve(typeof(IEnumerable<>).MakeGenericType(t)); + }); + + builder.RegisterGenericDecorator(typeof(LogDecorator<,>), + typeof(IAsyncRequestHandler<,>), + "IAsyncRequestHandler"); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs new file mode 100644 index 000000000..2125fcd7f --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/Filters/HttpGlobalExceptionFilter.cs @@ -0,0 +1,45 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Filters +{ + using Microsoft.AspNetCore.Hosting; + using Microsoft.AspNetCore.Mvc.Filters; + using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.ActionResults; + using Microsoft.Extensions.Logging; + + public class HttpGlobalExceptionFilter : IExceptionFilter + { + private readonly IHostingEnvironment env; + private readonly ILogger logger; + + public HttpGlobalExceptionFilter(IHostingEnvironment env, ILogger logger) + { + this.env = env; + this.logger = logger; + } + + public void OnException(ExceptionContext context) + { + logger.LogError(new EventId(context.Exception.HResult), + context.Exception, + context.Exception.Message); + + var json = new JsonErrorResponse + { + Messages = new[] { "An error ocurr.Try it again." } + }; + + if (env.IsDevelopment()) + { + json.DeveloperMeesage = context.Exception; + } + + context.Result = new InternalServerErrorObjectResult(json); + } + + private class JsonErrorResponse + { + public string[] Messages { get; set; } + + public object DeveloperMeesage { get; set; } + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161124133626_InitialModel.Designer.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161124133626_InitialModel.Designer.cs new file mode 100644 index 000000000..f7d11fbfb --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161124133626_InitialModel.Designer.cs @@ -0,0 +1,227 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; + +namespace Ordering.API.Infrastructure.Migrations +{ + [DbContext(typeof(OrderingContext))] + [Migration("20161124133626_InitialModel")] + partial class InitialModel + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.0.1") + .HasAnnotation("SqlServer:Sequence:ordering.buyerseq", "'buyerseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:Sequence:ordering.orderseq", "'orderseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:Sequence:ordering.paymentseq", "'paymentseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("City"); + + b.Property("Country"); + + b.Property("State"); + + b.Property("Street"); + + b.Property("ZipCode"); + + b.HasKey("Id"); + + b.ToTable("address","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Buyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "buyerseq") + .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("FullName") + .IsRequired() + .HasAnnotation("MaxLength", 200); + + b.HasKey("Id"); + + b.HasIndex("FullName") + .IsUnique(); + + b.ToTable("buyers","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.CardType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasDefaultValue(1); + + b.Property("Name") + .IsRequired() + .HasAnnotation("MaxLength", 200); + + b.HasKey("Id"); + + b.ToTable("cardtypes","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "orderseq") + .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("BuyerId"); + + b.Property("OrderDate"); + + b.Property("PaymentId"); + + b.Property("ShippingAddressId"); + + b.Property("StatusId"); + + b.HasKey("Id"); + + b.HasIndex("BuyerId"); + + b.HasIndex("PaymentId"); + + b.HasIndex("ShippingAddressId"); + + b.HasIndex("StatusId"); + + b.ToTable("orders","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Discount"); + + b.Property("OrderId"); + + b.Property("ProductId"); + + b.Property("ProductName") + .IsRequired(); + + b.Property("UnitPrice"); + + b.Property("Units") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:DefaultValue", 1); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("orderItems","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.OrderStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasDefaultValue(1); + + b.Property("Name") + .IsRequired() + .HasAnnotation("MaxLength", 200); + + b.HasKey("Id"); + + b.ToTable("orderstatus","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "paymentseq") + .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("BuyerId"); + + b.Property("CardHolderName") + .IsRequired() + .HasAnnotation("MaxLength", 200); + + b.Property("CardNumber") + .IsRequired() + .HasAnnotation("MaxLength", 25); + + b.Property("CardTypeId"); + + b.Property("Expiration"); + + b.Property("SecurityNumber"); + + b.HasKey("Id"); + + b.HasIndex("BuyerId"); + + b.HasIndex("CardTypeId"); + + b.ToTable("payments","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Buyer", "Buyer") + .WithMany() + .HasForeignKey("BuyerId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Payment", "Payment") + .WithMany() + .HasForeignKey("PaymentId"); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Address", "ShippingAddress") + .WithMany() + .HasForeignKey("ShippingAddressId"); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.OrderStatus", "Status") + .WithMany() + .HasForeignKey("StatusId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.OrderItem", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order") + .WithMany("OrderItems") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Payment", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Buyer") + .WithMany("Payments") + .HasForeignKey("BuyerId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.CardType", "CardType") + .WithMany() + .HasForeignKey("CardTypeId") + .OnDelete(DeleteBehavior.Cascade); + }); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161124133626_InitialModel.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161124133626_InitialModel.cs new file mode 100644 index 000000000..e60cf281f --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161124133626_InitialModel.cs @@ -0,0 +1,283 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Metadata; + +namespace Ordering.API.Infrastructure.Migrations +{ + public partial class InitialModel : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "ordering"); + + migrationBuilder.CreateSequence( + name: "buyerseq", + schema: "ordering", + incrementBy: 10); + + migrationBuilder.CreateSequence( + name: "orderseq", + schema: "ordering", + incrementBy: 10); + + migrationBuilder.CreateSequence( + name: "paymentseq", + schema: "ordering", + incrementBy: 10); + + migrationBuilder.CreateTable( + name: "address", + schema: "ordering", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + City = table.Column(nullable: true), + Country = table.Column(nullable: true), + State = table.Column(nullable: true), + Street = table.Column(nullable: true), + ZipCode = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_address", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "buyers", + schema: "ordering", + columns: table => new + { + Id = table.Column(nullable: false), + FullName = table.Column(maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_buyers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "cardtypes", + schema: "ordering", + columns: table => new + { + Id = table.Column(nullable: false, defaultValue: 1), + Name = table.Column(maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_cardtypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "orderstatus", + schema: "ordering", + columns: table => new + { + Id = table.Column(nullable: false, defaultValue: 1), + Name = table.Column(maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_orderstatus", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "payments", + schema: "ordering", + columns: table => new + { + Id = table.Column(nullable: false), + BuyerId = table.Column(nullable: false), + CardHolderName = table.Column(maxLength: 200, nullable: false), + CardNumber = table.Column(maxLength: 25, nullable: false), + CardTypeId = table.Column(nullable: false), + Expiration = table.Column(nullable: false), + SecurityNumber = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_payments", x => x.Id); + table.ForeignKey( + name: "FK_payments_buyers_BuyerId", + column: x => x.BuyerId, + principalSchema: "ordering", + principalTable: "buyers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_payments_cardtypes_CardTypeId", + column: x => x.CardTypeId, + principalSchema: "ordering", + principalTable: "cardtypes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "orders", + schema: "ordering", + columns: table => new + { + Id = table.Column(nullable: false), + BuyerId = table.Column(nullable: false), + OrderDate = table.Column(nullable: false), + PaymentId = table.Column(nullable: false), + ShippingAddressId = table.Column(nullable: true), + StatusId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_orders", x => x.Id); + table.ForeignKey( + name: "FK_orders_buyers_BuyerId", + column: x => x.BuyerId, + principalSchema: "ordering", + principalTable: "buyers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_orders_payments_PaymentId", + column: x => x.PaymentId, + principalSchema: "ordering", + principalTable: "payments", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_orders_address_ShippingAddressId", + column: x => x.ShippingAddressId, + principalSchema: "ordering", + principalTable: "address", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_orders_orderstatus_StatusId", + column: x => x.StatusId, + principalSchema: "ordering", + principalTable: "orderstatus", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "orderItems", + schema: "ordering", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn), + Discount = table.Column(nullable: false), + OrderId = table.Column(nullable: false), + ProductId = table.Column(nullable: false), + ProductName = table.Column(nullable: false), + UnitPrice = table.Column(nullable: false), + Units = table.Column(nullable: false, defaultValue: 1) + }, + constraints: table => + { + table.PrimaryKey("PK_orderItems", x => x.Id); + table.ForeignKey( + name: "FK_orderItems_orders_OrderId", + column: x => x.OrderId, + principalSchema: "ordering", + principalTable: "orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_buyers_FullName", + schema: "ordering", + table: "buyers", + column: "FullName", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_orders_BuyerId", + schema: "ordering", + table: "orders", + column: "BuyerId"); + + migrationBuilder.CreateIndex( + name: "IX_orders_PaymentId", + schema: "ordering", + table: "orders", + column: "PaymentId"); + + migrationBuilder.CreateIndex( + name: "IX_orders_ShippingAddressId", + schema: "ordering", + table: "orders", + column: "ShippingAddressId"); + + migrationBuilder.CreateIndex( + name: "IX_orders_StatusId", + schema: "ordering", + table: "orders", + column: "StatusId"); + + migrationBuilder.CreateIndex( + name: "IX_orderItems_OrderId", + schema: "ordering", + table: "orderItems", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_payments_BuyerId", + schema: "ordering", + table: "payments", + column: "BuyerId"); + + migrationBuilder.CreateIndex( + name: "IX_payments_CardTypeId", + schema: "ordering", + table: "payments", + column: "CardTypeId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropSequence( + name: "buyerseq", + schema: "ordering"); + + migrationBuilder.DropSequence( + name: "orderseq", + schema: "ordering"); + + migrationBuilder.DropSequence( + name: "paymentseq", + schema: "ordering"); + + migrationBuilder.DropTable( + name: "orderItems", + schema: "ordering"); + + migrationBuilder.DropTable( + name: "orders", + schema: "ordering"); + + migrationBuilder.DropTable( + name: "payments", + schema: "ordering"); + + migrationBuilder.DropTable( + name: "address", + schema: "ordering"); + + migrationBuilder.DropTable( + name: "orderstatus", + schema: "ordering"); + + migrationBuilder.DropTable( + name: "buyers", + schema: "ordering"); + + migrationBuilder.DropTable( + name: "cardtypes", + schema: "ordering"); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs new file mode 100644 index 000000000..75837ccef --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs @@ -0,0 +1,226 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure; + +namespace Ordering.API.Infrastructure.Migrations +{ + [DbContext(typeof(OrderingContext))] + partial class OrderingContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.0.1") + .HasAnnotation("SqlServer:Sequence:ordering.buyerseq", "'buyerseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:Sequence:ordering.orderseq", "'orderseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:Sequence:ordering.paymentseq", "'paymentseq', 'ordering', '1', '10', '', '', 'Int64', 'False'") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("City"); + + b.Property("Country"); + + b.Property("State"); + + b.Property("Street"); + + b.Property("ZipCode"); + + b.HasKey("Id"); + + b.ToTable("address","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Buyer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "buyerseq") + .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("FullName") + .IsRequired() + .HasAnnotation("MaxLength", 200); + + b.HasKey("Id"); + + b.HasIndex("FullName") + .IsUnique(); + + b.ToTable("buyers","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.CardType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasDefaultValue(1); + + b.Property("Name") + .IsRequired() + .HasAnnotation("MaxLength", 200); + + b.HasKey("Id"); + + b.ToTable("cardtypes","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "orderseq") + .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("BuyerId"); + + b.Property("OrderDate"); + + b.Property("PaymentId"); + + b.Property("ShippingAddressId"); + + b.Property("StatusId"); + + b.HasKey("Id"); + + b.HasIndex("BuyerId"); + + b.HasIndex("PaymentId"); + + b.HasIndex("ShippingAddressId"); + + b.HasIndex("StatusId"); + + b.ToTable("orders","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.OrderItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Discount"); + + b.Property("OrderId"); + + b.Property("ProductId"); + + b.Property("ProductName") + .IsRequired(); + + b.Property("UnitPrice"); + + b.Property("Units") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:DefaultValue", 1); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("orderItems","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.OrderStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasDefaultValue(1); + + b.Property("Name") + .IsRequired() + .HasAnnotation("MaxLength", 200); + + b.HasKey("Id"); + + b.ToTable("orderstatus","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasAnnotation("SqlServer:HiLoSequenceName", "paymentseq") + .HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo); + + b.Property("BuyerId"); + + b.Property("CardHolderName") + .IsRequired() + .HasAnnotation("MaxLength", 200); + + b.Property("CardNumber") + .IsRequired() + .HasAnnotation("MaxLength", 25); + + b.Property("CardTypeId"); + + b.Property("Expiration"); + + b.Property("SecurityNumber"); + + b.HasKey("Id"); + + b.HasIndex("BuyerId"); + + b.HasIndex("CardTypeId"); + + b.ToTable("payments","ordering"); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Buyer", "Buyer") + .WithMany() + .HasForeignKey("BuyerId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Payment", "Payment") + .WithMany() + .HasForeignKey("PaymentId"); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Address", "ShippingAddress") + .WithMany() + .HasForeignKey("ShippingAddressId"); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.OrderStatus", "Status") + .WithMany() + .HasForeignKey("StatusId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.OrderItem", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order") + .WithMany("OrderItems") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Payment", b => + { + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Buyer") + .WithMany("Payments") + .HasForeignKey("BuyerId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.CardType", "CardType") + .WithMany() + .HasForeignKey("CardTypeId") + .OnDelete(DeleteBehavior.Cascade); + }); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs new file mode 100644 index 000000000..017bb2aaa --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs @@ -0,0 +1,42 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure +{ + using AspNetCore.Builder; + using Microsoft.EntityFrameworkCore; + using Microsoft.eShopOnContainers.Services.Ordering.Domain; + using Ordering.Infrastructure; + using System.Linq; + using System.Threading.Tasks; + + public class OrderingContextSeed + { + public static async Task SeedAsync(IApplicationBuilder applicationBuilder) + { + var context = (OrderingContext)applicationBuilder + .ApplicationServices.GetService(typeof(OrderingContext)); + + using (context) + { + context.Database.Migrate(); + + if (!context.CardTypes.Any()) + { + context.CardTypes.Add(CardType.Amex); + context.CardTypes.Add(CardType.Visa); + context.CardTypes.Add(CardType.MasterCard); + + await context.SaveChangesAsync(); + } + + if (!context.OrderStatus.Any()) + { + context.OrderStatus.Add(OrderStatus.Canceled); + context.OrderStatus.Add(OrderStatus.InProcess); + context.OrderStatus.Add(OrderStatus.Shipped); + } + + await context.SaveChangesAsync(); + } + } + + } +} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20160913204939_Migration1.Designer.cs b/src/Services/Ordering/Ordering.API/Migrations/20160913204939_Migration1.Designer.cs deleted file mode 100644 index 68d9f6d9e..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20160913204939_Migration1.Designer.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; - -namespace Ordering.API.Migrations -{ - [DbContext(typeof(OrderingDbContext))] - [Migration("20160913204939_Migration1")] - partial class Migration1 - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") - .HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("City"); - - b.Property("Country"); - - b.Property("CountryCode"); - - b.Property("Latitude"); - - b.Property("Longitude"); - - b.Property("State"); - - b.Property("StateCode"); - - b.Property("Street"); - - b.Property("ZipCode"); - - b.HasKey("Id"); - - b.ToTable("Address"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("BillingAddressId"); - - b.Property("BuyerId"); - - b.Property("OrderDate"); - - b.Property("SequenceNumber") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); - - b.Property("ShippingAddressId"); - - b.Property("Status"); - - b.HasKey("Id"); - - b.HasIndex("BillingAddressId"); - - b.HasIndex("ShippingAddressId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Discount"); - - b.Property("FulfillmentRemaining"); - - b.Property("OrderId"); - - b.Property("ProductId"); - - b.Property("Quantity"); - - b.Property("UnitPrice"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.ToTable("OrderItem"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "BillingAddress") - .WithMany() - .HasForeignKey("BillingAddressId"); - - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "ShippingAddress") - .WithMany() - .HasForeignKey("ShippingAddressId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order") - .WithMany("OrderItems") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20160913204939_Migration1.cs b/src/Services/Ordering/Ordering.API/Migrations/20160913204939_Migration1.cs deleted file mode 100644 index 1d9dcc444..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20160913204939_Migration1.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Ordering.API.Migrations -{ - public partial class Migration1 : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "shared"); - - migrationBuilder.CreateSequence( - name: "OrderSequences", - schema: "shared", - startValue: 1001L); - - migrationBuilder.CreateTable( - name: "Address", - columns: table => new - { - Id = table.Column(nullable: false), - City = table.Column(nullable: true), - Country = table.Column(nullable: true), - CountryCode = table.Column(nullable: true), - Latitude = table.Column(nullable: false), - Longitude = table.Column(nullable: false), - State = table.Column(nullable: true), - StateCode = table.Column(nullable: true), - Street = table.Column(nullable: true), - ZipCode = table.Column(nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Address", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Orders", - columns: table => new - { - Id = table.Column(nullable: false), - BillingAddressId = table.Column(nullable: true), - BuyerId = table.Column(nullable: false), - OrderDate = table.Column(nullable: false), - SequenceNumber = table.Column(nullable: false, defaultValueSql: "NEXT VALUE FOR shared.OrderSequences"), - ShippingAddressId = table.Column(nullable: true), - Status = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Orders", x => x.Id); - table.ForeignKey( - name: "FK_Orders_Address_BillingAddressId", - column: x => x.BillingAddressId, - principalTable: "Address", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_Orders_Address_ShippingAddressId", - column: x => x.ShippingAddressId, - principalTable: "Address", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "OrderItem", - columns: table => new - { - Id = table.Column(nullable: false), - Discount = table.Column(nullable: false), - FulfillmentRemaining = table.Column(nullable: false), - OrderId = table.Column(nullable: false), - ProductId = table.Column(nullable: false), - Quantity = table.Column(nullable: false), - UnitPrice = table.Column(nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_OrderItem", x => x.Id); - table.ForeignKey( - name: "FK_OrderItem_Orders_OrderId", - column: x => x.OrderId, - principalTable: "Orders", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Orders_BillingAddressId", - table: "Orders", - column: "BillingAddressId"); - - migrationBuilder.CreateIndex( - name: "IX_Orders_ShippingAddressId", - table: "Orders", - column: "ShippingAddressId"); - - migrationBuilder.CreateIndex( - name: "IX_OrderItem_OrderId", - table: "OrderItem", - column: "OrderId"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropSequence( - name: "OrderSequences", - schema: "shared"); - - migrationBuilder.DropTable( - name: "OrderItem"); - - migrationBuilder.DropTable( - name: "Orders"); - - migrationBuilder.DropTable( - name: "Address"); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20161005002014_Migration_Baseline.Designer.cs b/src/Services/Ordering/Ordering.API/Migrations/20161005002014_Migration_Baseline.Designer.cs deleted file mode 100644 index c1408c1a3..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20161005002014_Migration_Baseline.Designer.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; - -namespace Ordering.API.Migrations -{ - [DbContext(typeof(OrderingDbContext))] - [Migration("20161005002014_Migration_Baseline")] - partial class Migration_Baseline - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") - .HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("City"); - - b.Property("Country"); - - b.Property("CountryCode"); - - b.Property("Latitude"); - - b.Property("Longitude"); - - b.Property("State"); - - b.Property("StateCode"); - - b.Property("Street"); - - b.Property("ZipCode"); - - b.HasKey("Id"); - - b.ToTable("Address"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("BillingAddressId"); - - b.Property("BuyerId"); - - b.Property("OrderDate"); - - b.Property("SequenceNumber") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); - - b.Property("ShippingAddressId"); - - b.Property("Status"); - - b.HasKey("Id"); - - b.HasIndex("BillingAddressId"); - - b.HasIndex("ShippingAddressId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Discount"); - - b.Property("FulfillmentRemaining"); - - b.Property("OrderId"); - - b.Property("ProductId"); - - b.Property("Quantity"); - - b.Property("UnitPrice"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.ToTable("OrderItem"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "BillingAddress") - .WithMany() - .HasForeignKey("BillingAddressId"); - - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "ShippingAddress") - .WithMany() - .HasForeignKey("ShippingAddressId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order") - .WithMany("OrderItems") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20161005002014_Migration_Baseline.cs b/src/Services/Ordering/Ordering.API/Migrations/20161005002014_Migration_Baseline.cs deleted file mode 100644 index ab54ddc1c..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20161005002014_Migration_Baseline.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Ordering.API.Migrations -{ - public partial class Migration_Baseline : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20161005003321_Migration_Cero.Designer.cs b/src/Services/Ordering/Ordering.API/Migrations/20161005003321_Migration_Cero.Designer.cs deleted file mode 100644 index 23b3007c4..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20161005003321_Migration_Cero.Designer.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; - -namespace Ordering.API.Migrations -{ - [DbContext(typeof(OrderingDbContext))] - [Migration("20161005003321_Migration_Cero")] - partial class Migration_Cero - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") - .HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("City"); - - b.Property("Country"); - - b.Property("CountryCode"); - - b.Property("Latitude"); - - b.Property("Longitude"); - - b.Property("State"); - - b.Property("StateCode"); - - b.Property("Street"); - - b.Property("ZipCode"); - - b.HasKey("Id"); - - b.ToTable("Address"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("BillingAddressId"); - - b.Property("BuyerId"); - - b.Property("OrderDate"); - - b.Property("SequenceNumber") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); - - b.Property("ShippingAddressId"); - - b.Property("Status"); - - b.HasKey("Id"); - - b.HasIndex("BillingAddressId"); - - b.HasIndex("ShippingAddressId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Discount"); - - b.Property("FulfillmentRemaining"); - - b.Property("OrderId"); - - b.Property("ProductId"); - - b.Property("Quantity"); - - b.Property("UnitPrice"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.ToTable("OrderItem"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "BillingAddress") - .WithMany() - .HasForeignKey("BillingAddressId"); - - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "ShippingAddress") - .WithMany() - .HasForeignKey("ShippingAddressId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order") - .WithMany("OrderItems") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20161005003321_Migration_Cero.cs b/src/Services/Ordering/Ordering.API/Migrations/20161005003321_Migration_Cero.cs deleted file mode 100644 index aec42924e..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20161005003321_Migration_Cero.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Ordering.API.Migrations -{ - public partial class Migration_Cero : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20161011040943_Migration2.Designer.cs b/src/Services/Ordering/Ordering.API/Migrations/20161011040943_Migration2.Designer.cs deleted file mode 100644 index 9728a1902..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20161011040943_Migration2.Designer.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; - -namespace Ordering.API.Migrations -{ - [DbContext(typeof(OrderingDbContext))] - [Migration("20161011040943_Migration2")] - partial class Migration2 - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") - .HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("City"); - - b.Property("Country"); - - b.Property("CountryCode"); - - b.Property("Latitude"); - - b.Property("Longitude"); - - b.Property("State"); - - b.Property("StateCode"); - - b.Property("Street"); - - b.Property("ZipCode"); - - b.HasKey("Id"); - - b.ToTable("Address"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("BillingAddressId"); - - b.Property("BuyerId"); - - b.Property("OrderDate"); - - b.Property("SequenceNumber") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); - - b.Property("ShippingAddressId"); - - b.Property("Status"); - - b.HasKey("Id"); - - b.HasIndex("BillingAddressId"); - - b.HasIndex("ShippingAddressId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Discount"); - - b.Property("FulfillmentRemaining"); - - b.Property("OrderId"); - - b.Property("ProductId"); - - b.Property("ProductName"); - - b.Property("Quantity"); - - b.Property("UnitPrice"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.ToTable("OrderItem"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "BillingAddress") - .WithMany() - .HasForeignKey("BillingAddressId"); - - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "ShippingAddress") - .WithMany() - .HasForeignKey("ShippingAddressId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order") - .WithMany("OrderItems") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20161011040943_Migration2.cs b/src/Services/Ordering/Ordering.API/Migrations/20161011040943_Migration2.cs deleted file mode 100644 index caf45e9c0..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20161011040943_Migration2.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Ordering.API.Migrations -{ - public partial class Migration2 : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "ProductName", - table: "OrderItem", - nullable: true); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ProductName", - table: "OrderItem"); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20161011041130_Migration3.Designer.cs b/src/Services/Ordering/Ordering.API/Migrations/20161011041130_Migration3.Designer.cs deleted file mode 100644 index f0d76e51f..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20161011041130_Migration3.Designer.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; - -namespace Ordering.API.Migrations -{ - [DbContext(typeof(OrderingDbContext))] - [Migration("20161011041130_Migration3")] - partial class Migration3 - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") - .HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("City"); - - b.Property("Country"); - - b.Property("CountryCode"); - - b.Property("Latitude"); - - b.Property("Longitude"); - - b.Property("State"); - - b.Property("StateCode"); - - b.Property("Street"); - - b.Property("ZipCode"); - - b.HasKey("Id"); - - b.ToTable("Address"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("BillingAddressId"); - - b.Property("BuyerId"); - - b.Property("OrderDate"); - - b.Property("SequenceNumber") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); - - b.Property("ShippingAddressId"); - - b.Property("Status"); - - b.HasKey("Id"); - - b.HasIndex("BillingAddressId"); - - b.HasIndex("ShippingAddressId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Discount"); - - b.Property("FulfillmentRemaining"); - - b.Property("OrderId"); - - b.Property("ProductId"); - - b.Property("ProductName"); - - b.Property("Quantity"); - - b.Property("UnitPrice"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.ToTable("OrderItem"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "BillingAddress") - .WithMany() - .HasForeignKey("BillingAddressId"); - - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "ShippingAddress") - .WithMany() - .HasForeignKey("ShippingAddressId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order") - .WithMany("OrderItems") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20161011041130_Migration3.cs b/src/Services/Ordering/Ordering.API/Migrations/20161011041130_Migration3.cs deleted file mode 100644 index 3b3ae2b73..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/20161011041130_Migration3.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace Ordering.API.Migrations -{ - public partial class Migration3 : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Migrations/OrderingDbContextModelSnapshot.cs b/src/Services/Ordering/Ordering.API/Migrations/OrderingDbContextModelSnapshot.cs deleted file mode 100644 index e7b7b4aaf..000000000 --- a/src/Services/Ordering/Ordering.API/Migrations/OrderingDbContextModelSnapshot.cs +++ /dev/null @@ -1,122 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; - -namespace Ordering.API.Migrations -{ - [DbContext(typeof(OrderingDbContext))] - partial class OrderingDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { - modelBuilder - .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") - .HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("City"); - - b.Property("Country"); - - b.Property("CountryCode"); - - b.Property("Latitude"); - - b.Property("Longitude"); - - b.Property("State"); - - b.Property("StateCode"); - - b.Property("Street"); - - b.Property("ZipCode"); - - b.HasKey("Id"); - - b.ToTable("Address"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("BillingAddressId"); - - b.Property("BuyerId"); - - b.Property("OrderDate"); - - b.Property("SequenceNumber") - .ValueGeneratedOnAdd() - .HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); - - b.Property("ShippingAddressId"); - - b.Property("Status"); - - b.HasKey("Id"); - - b.HasIndex("BillingAddressId"); - - b.HasIndex("ShippingAddressId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Discount"); - - b.Property("FulfillmentRemaining"); - - b.Property("OrderId"); - - b.Property("ProductId"); - - b.Property("ProductName"); - - b.Property("Quantity"); - - b.Property("UnitPrice"); - - b.HasKey("Id"); - - b.HasIndex("OrderId"); - - b.ToTable("OrderItem"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "BillingAddress") - .WithMany() - .HasForeignKey("BillingAddressId"); - - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "ShippingAddress") - .WithMany() - .HasForeignKey("ShippingAddressId"); - }); - - modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => - { - b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order") - .WithMany("OrderItems") - .HasForeignKey("OrderId") - .OnDelete(DeleteBehavior.Cascade); - }); - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Models/NewOrderViewModel.cs b/src/Services/Ordering/Ordering.API/Models/NewOrderViewModel.cs new file mode 100644 index 000000000..c79e3c3bf --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Models/NewOrderViewModel.cs @@ -0,0 +1,25 @@ +using System; + +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Models +{ + public class NewOrderViewModel + { + public string ShippingCity { get; set; } + + public string ShippingStreet { get; set; } + + public string ShippingState { get; set; } + + public string ShippingCountry { get; set; } + + public string CardType { get; set; } + + public string CardNumber { get; set; } + + public string CardHolderName { get; set; } + + public DateTime CardExpiration { get; set; } + + public string CardSecurityNumber { get; set; } + } +} diff --git a/src/Services/Ordering/Ordering.API/Project_Readme.html b/src/Services/Ordering/Ordering.API/Project_Readme.html deleted file mode 100644 index 1a0f5b51a..000000000 --- a/src/Services/Ordering/Ordering.API/Project_Readme.html +++ /dev/null @@ -1,187 +0,0 @@ - - - - - Welcome to ASP.NET Core - - - - - - - - - - diff --git a/src/Services/Ordering/Ordering.API/Properties/launchSettings.json b/src/Services/Ordering/Ordering.API/Properties/launchSettings.json index faa3c234a..150597acd 100644 --- a/src/Services/Ordering/Ordering.API/Properties/launchSettings.json +++ b/src/Services/Ordering/Ordering.API/Properties/launchSettings.json @@ -11,7 +11,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "api/environmentInfo/machinename", + "launchUrl": "/swagger/ui", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 8e003d8e5..58c3d8442 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -1,29 +1,29 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; - -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; -using Microsoft.EntityFrameworkCore; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.Repositories; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries; - -namespace Microsoft.eShopOnContainers.Services.Ordering.API +namespace Microsoft.eShopOnContainers.Services.Ordering.API { + using Autofac; + using Autofac.Extensions.DependencyInjection; + using Infrastructure; + using Infrastructure.AutofacModules; + using Infrastructure.Filters; + using MediatR; + using Microsoft.AspNetCore.Builder; + using Microsoft.AspNetCore.Hosting; + using Microsoft.EntityFrameworkCore; + using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Logging; + using Ordering.Infrastructure; + using System; + using System.Reflection; + public class Startup { public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) - .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) - .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true); + .AddJsonFile("settings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true); if (env.IsDevelopment()) { @@ -37,27 +37,55 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API public IConfigurationRoot Configuration { get; } - // This method gets called by the runtime. - // Use this method to add services to the IoC container. - public void ConfigureServices(IServiceCollection services) + public IServiceProvider ConfigureServices(IServiceCollection services) { // Add framework services. - services.AddMvc(); - - var connString = Configuration["ConnectionString"]; + services.AddMvc(options=> + { + + options.Filters.Add(typeof(HttpGlobalExceptionFilter)); + + }).AddControllersAsServices(); - services.AddDbContext(options => + services.AddEntityFrameworkSqlServer() + .AddDbContext(options => + { + options.UseSqlServer(Configuration["ConnectionString"], + sqlop=>sqlop.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name)); + }); + + services.AddSwaggerGen(); + services.ConfigureSwaggerGen(options => { - options.UseSqlServer(connString) - .UseSqlServer(connString, b => b.MigrationsAssembly("Ordering.API")); + options.DescribeAllEnumsAsStrings(); + options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info() + { + Title = "Ordering HTTP API", + Version = "v1", + Description = "The Ordering Service HTTP API", + TermsOfService = "Terms Of Service" + }); }); - services.AddTransient(); - services.AddTransient(); + services.AddSingleton(this.Configuration); + + services.AddOptions(); + + + + //configure autofac + + var container = new ContainerBuilder(); + container.Populate(services); + + container.RegisterModule(new MediatorModule()); + container.RegisterModule(new ApplicationModule()); + + + return new AutofacServiceProvider(container.Build()); } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); @@ -67,8 +95,13 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API { app.UseDeveloperExceptionPage(); } - + + OrderingContextSeed.SeedAsync(app).Wait(); + app.UseMvc(); + + app.UseSwagger() + .UseSwaggerUi(); } } } diff --git a/src/Services/Ordering/Ordering.API/docker-compose.yml b/src/Services/Ordering/Ordering.API/docker-compose.yml index cb76c339d..4a31a1a26 100644 --- a/src/Services/Ordering/Ordering.API/docker-compose.yml +++ b/src/Services/Ordering/Ordering.API/docker-compose.yml @@ -10,16 +10,13 @@ services: - ConnectionString=Server=ordering.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word ports: - "81:80" -# (Go to Production): For secured/final deployment, remove Ports mapping and -# leave just the internal expose section -# expose: -# - "80" - extra_hosts: - - "CESARDLBOOKVHD:10.0.75.1" depends_on: - ordering.data ordering.data: - image: eshop/ordering.data.sqlserver.linux + image: microsoft/mssql-server-linux + environment: + - ACCEPT_EULA=Y + - SA_PASSWORD=Pass@word ports: - "1433:1433" \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/project.json b/src/Services/Ordering/Ordering.API/project.json index d5b415b26..f65f41ad6 100644 --- a/src/Services/Ordering/Ordering.API/project.json +++ b/src/Services/Ordering/Ordering.API/project.json @@ -1,9 +1,11 @@ { "dependencies": { "Microsoft.NETCore.App": { - "version": "1.0.0", + "version": "1.0.1", "type": "platform" }, + "MediatR.Extensions.Microsoft.DependencyInjection": "1.0.1", + "Autofac.Extensions.DependencyInjection": "4.0.0", "Microsoft.AspNetCore.Mvc": "1.0.0", "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", @@ -11,17 +13,21 @@ "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", - "Microsoft.Extensions.Logging": "1.0.0", + "Microsoft.Extensions.Logging.Abstractions": "1.0.0", "Microsoft.Extensions.Logging.Console": "1.0.0", "Microsoft.Extensions.Logging.Debug": "1.0.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", - "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", - "Microsoft.EntityFrameworkCore": "1.0.0", - "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0", - "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", + "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1", + "Microsoft.EntityFrameworkCore": "1.0.1", + "Microsoft.EntityFrameworkCore.Design" : "1.0.0-preview2-final", + "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.1", "Microsoft.AspNetCore.Diagnostics": "1.0.0", + "Swashbuckle": "6.0.0-beta902", + "MediatR": "2.1.0", "Ordering.Domain": "1.0.0-*", - "Ordering.SqlData": "1.0.0-*" + "Ordering.Application": "1.0.0-*", + "Ordering.Infrastructure": "1.0.0-*", + "System.Reflection": "4.3.0" }, "tools": { "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", @@ -63,5 +69,6 @@ "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] - } + }, + "userSecretsId": "aspnet-Ordering.API-20161122013547" } \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.API/settings.json b/src/Services/Ordering/Ordering.API/settings.json index da778d1c4..a95b8262f 100644 --- a/src/Services/Ordering/Ordering.API/settings.json +++ b/src/Services/Ordering/Ordering.API/settings.json @@ -1,3 +1,3 @@ { - "ConnectionString": "Server=127.0.0.1;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;" + "ConnectionString": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;" } diff --git a/src/Services/Ordering/Ordering.Application/Commands/NewOrderREquestHandler.cs b/src/Services/Ordering/Ordering.Application/Commands/NewOrderREquestHandler.cs new file mode 100644 index 000000000..2f321a685 --- /dev/null +++ b/src/Services/Ordering/Ordering.Application/Commands/NewOrderREquestHandler.cs @@ -0,0 +1,110 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Commands +{ + using Domain.Repositories; + using MediatR; + using System.Linq; + using System; + using System.Threading.Tasks; + using Domain; + + public class NewOrderRequestHandler + : IAsyncRequestHandler + { + private readonly IBuyerRepository _buyerRepository; + private readonly IOrderRepository _orderRepository; + + public NewOrderRequestHandler(IBuyerRepository buyerRepository,IOrderRepository orderRepository) + { + if (buyerRepository == null) + { + throw new ArgumentNullException(nameof(buyerRepository)); + } + + if (orderRepository == null) + { + throw new ArgumentNullException(nameof(orderRepository)); + } + + _buyerRepository = buyerRepository; + _orderRepository = orderRepository; + } + public async Task Handle(NewOrderRequest message) + { + //find buyer/payment or add a new one + + var buyer = await _buyerRepository.FindAsync(message.Buyer); + + if (buyer == null) + { + buyer = CreateBuyer(message); + } + + var payment = GetExistingPaymentOrAddANewOne(buyer, message); + + await _buyerRepository.UnitOfWork.SaveChangesAsync(); + + //create order + var order = CreateOrder(buyer.Id, payment.Id, 0); + order.SetAddress( new Address() + { + City = message.City, + State = message.State, + Street = message.Street, + ZipCode = message.ZipCode + }); + + _orderRepository.Add(order); + + var result = await _orderRepository.UnitOfWork.SaveChangesAsync(); + + return result > 0; + } + + + + Payment GetExistingPaymentOrAddANewOne(Buyer buyer, NewOrderRequest message) + { + Payment payment = PaymentAlreadyExist(buyer, message); + + if (payment == null) + { + payment = CreatePayment(message); + buyer.Payments.Add(payment); + } + + return payment; + + } + + Payment PaymentAlreadyExist(Domain.Buyer buyer, NewOrderRequest message) + { + return buyer.Payments + .SingleOrDefault(p => + { + return p.CardHolderName == message.CardHolderName + && + p.CardNumber == message.CardNumber + && + p.Expiration == message.CardExpiration + && + p.SecurityNumber == message.CardSecurityNumber; + }); + } + + Buyer CreateBuyer(NewOrderRequest message) + { + return _buyerRepository.Add( + new Buyer(message.Buyer)); + } + + Order CreateOrder(int buyerId, int paymentId, int addressId) + { + return new Order(buyerId, paymentId); + } + + Payment CreatePayment(NewOrderRequest message) + { + return new Payment(message.CardNumber, message.CardSecurityNumber, message.CardHolderName, message.CardExpiration, message.CardTypeId); + } + } +} diff --git a/src/Services/Ordering/Ordering.Application/Commands/NewOrderRequest.cs b/src/Services/Ordering/Ordering.Application/Commands/NewOrderRequest.cs new file mode 100644 index 000000000..108a4d98e --- /dev/null +++ b/src/Services/Ordering/Ordering.Application/Commands/NewOrderRequest.cs @@ -0,0 +1,35 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Commands +{ + using System; + using MediatR; + + public class NewOrderRequest + :IAsyncRequest + { + public string City { get; set; } + + public string Street { get; set; } + + public string State { get; set; } + + public string Country { get; set; } + + public string ZipCode { get; set; } + + public string CardNumber { get; set; } + + public string CardHolderName { get; set; } + + public DateTime CardExpiration { get; set; } + + public string CardSecurityNumber { get; set; } + + public int CardTypeId { get; set; } + + public string Buyer { get; set; } + + public NewOrderRequest() + { + } + } +} diff --git a/src/Services/Ordering/Ordering.Application/Decorators/LogDecorator.cs b/src/Services/Ordering/Ordering.Application/Decorators/LogDecorator.cs new file mode 100644 index 000000000..bc095a81e --- /dev/null +++ b/src/Services/Ordering/Ordering.Application/Decorators/LogDecorator.cs @@ -0,0 +1,34 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Decorators +{ + using Extensions.Logging; + using MediatR; + using System.Threading.Tasks; + + public class LogDecorator + : IAsyncRequestHandler + where TRequest : IAsyncRequest + { + private readonly IAsyncRequestHandler _inner; + private readonly ILogger> _logger; + + + public LogDecorator( + IAsyncRequestHandler inner, + ILogger> logger) + { + _inner = inner; + _logger = logger; + } + + public async Task Handle(TRequest message) + { + _logger.LogInformation($"Executing command {_inner.GetType().FullName}"); + + var response = await _inner.Handle(message); + + _logger.LogInformation($"Succedded executed command {_inner.GetType().FullName}"); + + return response; + } + } +} diff --git a/src/Services/Ordering/Ordering.SqlData/Ordering.SqlData.xproj b/src/Services/Ordering/Ordering.Application/Ordering.Application.xproj similarity index 86% rename from src/Services/Ordering/Ordering.SqlData/Ordering.SqlData.xproj rename to src/Services/Ordering/Ordering.Application/Ordering.Application.xproj index 5f9c67bd6..2c6ff9897 100644 --- a/src/Services/Ordering/Ordering.SqlData/Ordering.SqlData.xproj +++ b/src/Services/Ordering/Ordering.Application/Ordering.Application.xproj @@ -6,11 +6,11 @@ - 5da6ef13-c7e0-4ec4-8599-a61c6ac2628d - Microsoft.eShopOnContainers.Services.Ordering.SqlData + 4193caa3-a1c3-4818-a06f-a2d85fde77e7 + Microsoft.eShopOnContainers.Services.Ordering.Application .\obj .\bin\ - v4.6 + v4.5.1 2.0 diff --git a/src/Services/Ordering/Ordering.SqlData/Properties/AssemblyInfo.cs b/src/Services/Ordering/Ordering.Application/Properties/AssemblyInfo.cs similarity index 82% rename from src/Services/Ordering/Ordering.SqlData/Properties/AssemblyInfo.cs rename to src/Services/Ordering/Ordering.Application/Properties/AssemblyInfo.cs index 322d94a72..a38e1f35b 100644 --- a/src/Services/Ordering/Ordering.SqlData/Properties/AssemblyInfo.cs +++ b/src/Services/Ordering/Ordering.Application/Properties/AssemblyInfo.cs @@ -7,7 +7,7 @@ using System.Runtime.InteropServices; // associated with an assembly. [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Microsoft.eShopOnContainers.Services.Ordering.Infrastructure")] +[assembly: AssemblyProduct("Ordering.Application")] [assembly: AssemblyTrademark("")] // Setting ComVisible to false makes the types in this assembly not visible @@ -16,4 +16,4 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5da6ef13-c7e0-4ec4-8599-a61c6ac2628d")] +[assembly: Guid("4193caa3-a1c3-4818-a06f-a2d85fde77e7")] diff --git a/src/Services/Ordering/Ordering.Application/Queries/IOrderQueries.cs b/src/Services/Ordering/Ordering.Application/Queries/IOrderQueries.cs new file mode 100644 index 000000000..a011f2359 --- /dev/null +++ b/src/Services/Ordering/Ordering.Application/Queries/IOrderQueries.cs @@ -0,0 +1,13 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Queries +{ + using System.Threading.Tasks; + + public interface IOrderQueries + { + Task GetOrder(int id); + + Task GetOrders(); + + Task GetCardTypes(); + } +} diff --git a/src/Services/Ordering/Ordering.Application/Queries/OrderQueries.cs b/src/Services/Ordering/Ordering.Application/Queries/OrderQueries.cs new file mode 100644 index 000000000..97283546e --- /dev/null +++ b/src/Services/Ordering/Ordering.Application/Queries/OrderQueries.cs @@ -0,0 +1,55 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Queries +{ + using Dapper; + using Microsoft.Extensions.Configuration; + using System.Data.SqlClient; + using System.Threading.Tasks; + using System; + + public class OrderQueries + :IOrderQueries + { + private string _connectionString = string.Empty; + + public OrderQueries(IConfiguration configuration) + { + _connectionString = configuration["ConnectionString"]; + } + + + public async Task GetOrder(int id) + { + using (var connection = new SqlConnection(_connectionString)) + { + connection.Open(); + + return await connection.QueryAsync("SELECT * FROM ordering.Orders where Id=@id",new { id }); + } + } + + public async Task GetOrders() + { + using (var connection = new SqlConnection(_connectionString)) + { + connection.Open(); + + return await connection.QueryAsync(@"SELECT o.[Id] as ordernumber,o.[OrderDate] as [date],os.[Name] as [status],SUM(oi.units*oi.unitprice) as total + FROM [ordering].[Orders] o + LEFT JOIN[ordering].[orderitems] oi ON o.Id = oi.orderid + LEFT JOIN[ordering].[orderstatus] os on o.StatusId = os.Id + GROUP BY o.[Id], o.[OrderDate], os.[Name]"); + } + } + + public async Task GetCardTypes() + { + using (var connection = new SqlConnection(_connectionString)) + { + connection.Open(); + + return await connection.QueryAsync("SELECT * FROM ordering.cardtypes"); + } + } + + } +} diff --git a/src/Services/Ordering/Ordering.Application/project.json b/src/Services/Ordering/Ordering.Application/project.json new file mode 100644 index 000000000..158ae13d8 --- /dev/null +++ b/src/Services/Ordering/Ordering.Application/project.json @@ -0,0 +1,21 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "NETStandard.Library": "1.6.0", + "MediatR": "2.1.0", + "Dapper": "1.50.2", + "System.Dynamic.Runtime": "4.0.11", + "Microsoft.CSharp": "4.0.1", + "Microsoft.Extensions.Configuration": "1.0.0", + "System.Data.SqlClient": "4.1.0", + "Microsoft.Extensions.Logging.Abstractions": "1.0.0", + "Ordering.Domain": "1.0.0-*" + }, + + "frameworks": { + "netstandard1.6": { + "imports": "dnxcore50" + } + } +} diff --git a/src/Services/Ordering/Ordering.Domain/Address.cs b/src/Services/Ordering/Ordering.Domain/Address.cs new file mode 100644 index 000000000..154becb2c --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/Address.cs @@ -0,0 +1,20 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain +{ + using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; + using System; + + public class Address + : Entity + { + public String Street { get; set; } + + public String City { get; set; } + + public String State { get; set; } + + public String Country { get; set; } + + public String ZipCode { get; set; } + + } +} diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Buyer/Buyer.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Buyer/Buyer.cs deleted file mode 100644 index b10b087c4..000000000 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Buyer/Buyer.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel -{ - public class Buyer : Entity, IAggregateRoot - { - public Buyer(Guid buyerId, string name, string lastName, string email, Address address, string phoneNumber) - { - this.Id = buyerId; - this.Name = name; - this.LastName = lastName; - this.Email = email; - this.Address = address; - this.PhoneNumber = phoneNumber; - } - - - public virtual string Name - { - get; - private set; - } - - public virtual string LastName - { - get; - private set; - } - - public virtual string Email - { - get; - private set; - } - - public virtual Address Address - { - get; - private set; - } - - public virtual string PhoneNumber - { - get; - private set; - } - } -} diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Address.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Address.cs deleted file mode 100644 index 9114b2f93..000000000 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Address.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using System.Collections.Generic; - -using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel -{ - public class Address : ValueObject
- { - public Address(string street, - string city, - string state, - string stateCode, - string country, - string countryCode, - string zipCode, - double latitude = 0, - double longitude = 0 - ) - { - if (street == null) - throw new ArgumentNullException("street"); - - if (city == null) - throw new ArgumentNullException("city"); - - if (state == null) - throw new ArgumentNullException("state"); - - if (stateCode == null) - throw new ArgumentNullException("stateCode"); - - if (country == null) - throw new ArgumentNullException("country"); - - if (countryCode == null) - throw new ArgumentNullException("countryCode"); - - if (zipCode == null) - throw new ArgumentNullException("zipCode"); - - //Generate the ID guid - Remove this when EF Core supports ValueObjects - // https://github.com/aspnet/EntityFramework/issues/246 - this.Id = Guid.NewGuid(); - - this.Street = street; - this.City = city; - this.State = state; - this.StateCode = stateCode; - this.Country = country; - this.CountryCode = countryCode; - this.ZipCode = zipCode; - this.Latitude = latitude; - this.Longitude = longitude; - } - - //Infrastructure requisite - Parameterless constructor needed by EF - Address() { } - - public virtual String Street { get; private set; } - public virtual String City { get; private set; } - public virtual String State { get; private set; } - public virtual String StateCode { get; private set; } - public virtual String Country { get; private set; } - public virtual String CountryCode { get; private set; } - public virtual String ZipCode { get; private set; } - public virtual double Latitude { get; private set; } - public virtual double Longitude { get; private set; } - } -} diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Order.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Order.cs deleted file mode 100644 index 069afa981..000000000 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Order.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel -{ - public class Order : Entity, IAggregateRoot - { - public Order(Guid buyerId, Address shippingAddress, Address billingAddress) - : this(buyerId, shippingAddress, billingAddress, DateTime.UtcNow) - { - } - - public Order(Guid buyerId, Address shippingAddress, Address billingAddress, DateTime orderDate) - { - this.BuyerId = buyerId; - this.ShippingAddress = shippingAddress; - this.BillingAddress = billingAddress; - this.OrderDate = orderDate; - - this.Status = OrderStatus.New; - } - - //Infrastructure requisite - Parameterless constructor needed by EF - Order() { } - - //Order ID comes derived from the Entity base class - - List _orderItems; - public virtual List OrderItems - { - get - { - if (_orderItems == null) - _orderItems = new List(); - - return _orderItems; - } - - private set - { - _orderItems = value; - } - } - - public string OrderNumber - { - get - { - return string.Format("{0}/{1}-{2}", OrderDate.Year, OrderDate.Month, SequenceNumber); - } - } - - public int SequenceNumber { get; set; } - - public virtual Guid BuyerId { get; private set; } - - public virtual Address ShippingAddress { get; private set; } - - public virtual Address BillingAddress { get; private set; } - - public virtual DateTime OrderDate { get; private set; } - - public virtual OrderStatus Status { get; private set; } - - //////////////////////////////////////////////////////////////////////////////////////// - //Domain Rules and Logic in Order Aggregate-Root (Sample of a "NO ANEMIC DOMAIN MODEL" ) - //////////////////////////////////////////////////////////////////////////////////////// - - public OrderItem AddNewOrderItem(Guid productId, int quantity, decimal unitPrice, decimal discount) - { - //check preconditions - if (productId == Guid.Empty) - throw new ArgumentNullException("productId"); - - if (quantity <= 0) - { - throw new ArgumentException("The quantity of Product in an Order cannot be equal or less than cero"); - } - - //check discount values - if (discount < 0) - discount = 0; - - if (discount > 100) - discount = 100; - - //create new order line - var newOrderItem = new OrderItem() - { - OrderId = this.Id, - ProductId = productId, - Quantity = quantity, - FulfillmentRemaining = quantity, - Discount = discount, - UnitPrice = unitPrice - }; - - //set identity - newOrderItem.GenerateNewIdentity(); - - //add order item - this.OrderItems.Add(newOrderItem); - - //return added orderline - return newOrderItem; - } - } -} diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/OrderItem.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/OrderItem.cs deleted file mode 100644 index e993f7117..000000000 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/OrderItem.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using System.Runtime.Serialization; - -using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel -{ - public class OrderItem : Entity - { - public OrderItem() { } // Infrastructure. EF might need a plain constructor. Do not use. - - //NOTE: The OrderItem Id (Id) comes from the Entity base class - - public Guid ProductId { get; set; } - - public Guid OrderId { get; set; } - - public decimal UnitPrice { get; set; } - - public string ProductName { get; set; } - - public int Quantity { get; set; } - - public decimal Discount { get; set; } - - public int FulfillmentRemaining { get; set; } - - public override string ToString() - { - return String.Format("Product Id: {0}, Quantity: {1}, Fulfillment Remaing: {2}", this.Id, this.Quantity, this.FulfillmentRemaining); - } - } -} diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/OrderStatus.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/OrderStatus.cs deleted file mode 100644 index e48aaaaf1..000000000 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/OrderStatus.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel -{ - public enum OrderStatus - { - Unknown, - New, - Submitted, - InProcess, - Backordered, - Shipped, - Canceled, - } -} diff --git a/src/Services/Ordering/Ordering.Domain/Buyer.cs b/src/Services/Ordering/Ordering.Domain/Buyer.cs new file mode 100644 index 000000000..58634f342 --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/Buyer.cs @@ -0,0 +1,27 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain +{ + using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; + using System; + using System.Collections.Generic; + + public class Buyer + :Entity,IAggregateRoot + { + public string FullName { get; private set; } + + public HashSet Payments { get; private set; } + + protected Buyer() { } + + public Buyer(string fullName) + { + if (String.IsNullOrWhiteSpace(fullName)) + { + throw new ArgumentNullException(nameof(fullName)); + } + + this.FullName = fullName; + this.Payments = new HashSet(); + } + } +} diff --git a/src/Services/Ordering/Ordering.Domain/CardType.cs b/src/Services/Ordering/Ordering.Domain/CardType.cs new file mode 100644 index 000000000..b05357292 --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/CardType.cs @@ -0,0 +1,57 @@ + + +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain +{ + using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; + using System; + using System.Collections.Generic; + using System.Linq; + + public class CardType + : Entity + { + public static CardType Amex = new CardType(1, "Amex"); + public static CardType Visa = new CardType(2, "Visa"); + public static CardType MasterCard = new CardType(3, "MasterCard"); + + public string Name { get; private set; } + + protected CardType() { } + + public CardType(int id, string name) + { + Id = id; + Name = name; + } + + public static IEnumerable List() + { + return new[] { Amex, Visa, MasterCard }; + } + + public static CardType FromName(string name) + { + var state = List() + .SingleOrDefault(s => String.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase)); + + if (state == null) + { + throw new ArgumentException($"Possible values for CardType: {String.Join(",", List().Select(s => s.Name))}"); + } + + return state; + } + + public static CardType From(int id) + { + var state = List().SingleOrDefault(s => s.Id == id); + + if (state == null) + { + throw new ArgumentException($"Possible values for CardType: {String.Join(",", List().Select(s => s.Name))}"); + } + + return state; + } + } +} diff --git a/src/Services/Ordering/Ordering.Domain/Contracts/IBuyerRepository.cs b/src/Services/Ordering/Ordering.Domain/Contracts/IBuyerRepository.cs deleted file mode 100644 index fb5848ea8..000000000 --- a/src/Services/Ordering/Ordering.Domain/Contracts/IBuyerRepository.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts -{ - public interface IBuyerRepository : IRepository - { - //TBD - To define Specific Actions Not In Base Repo - } -} diff --git a/src/Services/Ordering/Ordering.Domain/Contracts/IOrderRepository.cs b/src/Services/Ordering/Ordering.Domain/Contracts/IOrderRepository.cs deleted file mode 100644 index 7e30b3dc7..000000000 --- a/src/Services/Ordering/Ordering.Domain/Contracts/IOrderRepository.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; - - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts -{ - public interface IOrderRepository : IRepository - { - void Add(Order order); - void Update(Order order); - Task Remove(Guid id); - Task FindAsync(Guid id); - } -} - diff --git a/src/Services/Ordering/Ordering.Domain/Order.cs b/src/Services/Ordering/Ordering.Domain/Order.cs new file mode 100644 index 000000000..2e6ee3cbd --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/Order.cs @@ -0,0 +1,50 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain +{ + using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; + using System; + using System.Collections.Generic; + + public class Order + : Entity, IAggregateRoot + { + public int BuyerId { get; private set; } + + public Buyer Buyer { get; private set; } + + public DateTime OrderDate { get; private set; } + + public int StatusId { get; private set; } + + public OrderStatus Status { get; private set; } + + public ICollection OrderItems { get; set; } + + public int? ShippingAddressId { get; private set; } + + public Address ShippingAddress { get; private set; } + + public int PaymentId { get; private set; } + + public Payment Payment { get; private set; } + + protected Order() { } + + public Order(int buyerId, int paymentId) + { + BuyerId = buyerId; + PaymentId = paymentId; + StatusId = OrderStatus.InProcess.Id; + OrderDate = DateTime.UtcNow; + } + + public void SetAddress(Address address) + { + if (address == null) + { + throw new ArgumentNullException(nameof(address)); + } + + ShippingAddress = address; + } + } +} diff --git a/src/Services/Ordering/Ordering.Domain/OrderItem.cs b/src/Services/Ordering/Ordering.Domain/OrderItem.cs new file mode 100644 index 000000000..2701ad9af --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/OrderItem.cs @@ -0,0 +1,25 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain +{ + using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; + + + public class OrderItem + :Entity + { + public int ProductId { get; private set; } + + public string ProductName { get; private set; } + + public int OrderId { get; private set; } + + public decimal UnitPrice { get; private set; } + + public decimal Discount { get; private set; } + + public int Units { get; private set; } + + protected OrderItem() + { + } + } +} diff --git a/src/Services/Ordering/Ordering.Domain/OrderStatus.cs b/src/Services/Ordering/Ordering.Domain/OrderStatus.cs new file mode 100644 index 000000000..e337da6f7 --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/OrderStatus.cs @@ -0,0 +1,57 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain +{ + using SeedWork; + using System; + using System.Collections.Generic; + using System.Linq; + + public class OrderStatus + :Entity + { + public string Name { get; private set; } + + public static OrderStatus InProcess = new OrderStatus(1, nameof(InProcess).ToLowerInvariant()); + public static OrderStatus Shipped = new OrderStatus(2, nameof(Shipped).ToLowerInvariant()); + public static OrderStatus Canceled = new OrderStatus(3, nameof(Canceled).ToLowerInvariant()); + + protected OrderStatus() + { + } + + public OrderStatus(int id, string name) + { + Id = id; + Name = name; + } + + public static IEnumerable List() + { + return new[] { InProcess, Shipped, Canceled }; + } + + public static OrderStatus FromName(string name) + { + var state = List() + .SingleOrDefault(s => String.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase)); + + if (state == null) + { + throw new ArgumentException($"Possible values for OrderStatus: {String.Join(",", List().Select(s => s.Name))}"); + } + + return state; + } + + public static OrderStatus From(int id) + { + var state = List().SingleOrDefault(s => s.Id == id); + + if (state == null) + { + throw new ArgumentException($"Possible values for OrderStatus: {String.Join(",", List().Select(s => s.Name))}"); + } + + return state; + } + } +} diff --git a/src/Services/Ordering/Ordering.Domain/Payment.cs b/src/Services/Ordering/Ordering.Domain/Payment.cs new file mode 100644 index 000000000..546b3482f --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/Payment.cs @@ -0,0 +1,55 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain +{ + using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; + using System; + + + public class Payment + : Entity + { + public int BuyerId { get; private set; } + + public string CardNumber { get; private set; } + + public string SecurityNumber { get; private set; } + + public string CardHolderName { get; private set; } + + public int CardTypeId { get; private set; } + + public CardType CardType { get; private set; } + + public DateTime Expiration { get; private set; } + + protected Payment() { } + + public Payment(string cardNumber, string securityNumber, string cardHolderName, DateTime expiration, int cardTypeId) + { + if (String.IsNullOrWhiteSpace(cardNumber)) + { + throw new ArgumentException(nameof(cardNumber)); + } + + if (String.IsNullOrWhiteSpace(securityNumber)) + { + throw new ArgumentException(nameof(securityNumber)); + } + + if (String.IsNullOrWhiteSpace(cardHolderName)) + { + throw new ArgumentException(nameof(cardHolderName)); + } + + if (expiration < DateTime.UtcNow) + { + throw new ArgumentException(nameof(expiration)); + } + + this.CardNumber = cardNumber; + this.SecurityNumber = securityNumber; + this.CardHolderName = cardHolderName; + this.Expiration = expiration; + this.CardTypeId = cardTypeId; + } + } +} diff --git a/src/Services/Ordering/Ordering.Domain/Repositories/IBuyerRepository.cs b/src/Services/Ordering/Ordering.Domain/Repositories/IBuyerRepository.cs new file mode 100644 index 000000000..5e41b7af6 --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/Repositories/IBuyerRepository.cs @@ -0,0 +1,13 @@ +using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; +using System.Threading.Tasks; + +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Repositories +{ + public interface IBuyerRepository + :IRepository + { + Buyer Add(Buyer buyer); + + Task FindAsync(string name); + } +} diff --git a/src/Services/Ordering/Ordering.Domain/Repositories/IOrderRepository.cs b/src/Services/Ordering/Ordering.Domain/Repositories/IOrderRepository.cs new file mode 100644 index 000000000..0648b00c5 --- /dev/null +++ b/src/Services/Ordering/Ordering.Domain/Repositories/IOrderRepository.cs @@ -0,0 +1,10 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Repositories +{ + using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; + + public interface IOrderRepository + :IRepository + { + Order Add(Order order); + } +} diff --git a/src/Services/Ordering/Ordering.Domain/SeedWork/Entity.cs b/src/Services/Ordering/Ordering.Domain/SeedWork/Entity.cs index 258b364e5..e5653ad28 100644 --- a/src/Services/Ordering/Ordering.Domain/SeedWork/Entity.cs +++ b/src/Services/Ordering/Ordering.Domain/SeedWork/Entity.cs @@ -1,24 +1,15 @@ -using System; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork +namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork { - /// - /// Base class for entities - /// + using System; + + public abstract class Entity { - //Members int? _requestedHashCode; - Guid _Id; - + int _Id; - //Properties - - /// - /// Get the persisten object identifier - /// - public virtual Guid Id + public virtual int Id { get { @@ -30,44 +21,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork } } - //Public Methods - - /// - /// Check if this entity is transient, ie, without identity at this moment - /// - /// True if entity is transient, else false public bool IsTransient() { - return this.Id == Guid.Empty; - } - - /// - /// Generate identity for this entity - /// - public void GenerateNewIdentity() - { - if ( IsTransient()) - this.Id = IdentityGenerator.NewSequentialGuid(); - } - - /// - /// Change current identity for a new non transient identity - /// - /// the new identity - public void ChangeCurrentIdentity(Guid identity) - { - if ( identity != Guid.Empty) - this.Id = identity; + return this.Id == default(Int32); } - - //Overrides Methods - - /// - /// - /// - /// - /// public override bool Equals(object obj) { if (obj == null || !(obj is Entity)) @@ -84,10 +42,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork return item.Id == this.Id; } - /// - /// - /// - /// public override int GetHashCode() { if (!IsTransient()) @@ -101,12 +55,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork return base.GetHashCode(); } - /// - /// equals operator - /// - /// left parameter - /// right parameter - /// true if equals + public static bool operator ==(Entity left, Entity right) { if (Object.Equals(left, null)) @@ -115,16 +64,9 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork return left.Equals(right); } - /// - /// Distinct operator - /// - /// left parameter - /// right parameter - /// True if different public static bool operator !=(Entity left, Entity right) { return !(left == right); } - } } diff --git a/src/Services/Ordering/Ordering.Domain/SeedWork/IUnitOfWork.cs b/src/Services/Ordering/Ordering.Domain/SeedWork/IUnitOfWork.cs index 802273f1f..fdbc61e79 100644 --- a/src/Services/Ordering/Ordering.Domain/SeedWork/IUnitOfWork.cs +++ b/src/Services/Ordering/Ordering.Domain/SeedWork/IUnitOfWork.cs @@ -1,10 +1,11 @@ using System; +using System.Threading; using System.Threading.Tasks; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork { public interface IUnitOfWork : IDisposable { - Task CommitAsync(); + Task SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)); } } diff --git a/src/Services/Ordering/Ordering.Domain/SeedWork/IdentityGenerator.cs b/src/Services/Ordering/Ordering.Domain/SeedWork/IdentityGenerator.cs deleted file mode 100644 index bc880ed78..000000000 --- a/src/Services/Ordering/Ordering.Domain/SeedWork/IdentityGenerator.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork -{ - internal static class IdentityGenerator - { - /// - /// This algorithm generates secuential GUIDs across system boundaries, ideal for databases - /// - /// - public static Guid NewSequentialGuid() - { - byte[] uid = Guid.NewGuid().ToByteArray(); - byte[] binDate = BitConverter.GetBytes(DateTime.UtcNow.Ticks); - - byte[] secuentialGuid = new byte[uid.Length]; - - secuentialGuid[0] = uid[0]; - secuentialGuid[1] = uid[1]; - secuentialGuid[2] = uid[2]; - secuentialGuid[3] = uid[3]; - secuentialGuid[4] = uid[4]; - secuentialGuid[5] = uid[5]; - secuentialGuid[6] = uid[6]; - // set the first part of the 8th byte to '1100' so - // later we'll be able to validate it was generated by us - - secuentialGuid[7] = (byte)(0xc0 | (0xf & uid[7])); - - // the last 8 bytes are sequential, - // it minimizes index fragmentation - // to a degree as long as there are not a large - // number of Secuential-Guids generated per millisecond - - secuentialGuid[9] = binDate[0]; - secuentialGuid[8] = binDate[1]; - secuentialGuid[15] = binDate[2]; - secuentialGuid[14] = binDate[3]; - secuentialGuid[13] = binDate[4]; - secuentialGuid[12] = binDate[5]; - secuentialGuid[11] = binDate[6]; - secuentialGuid[10] = binDate[7]; - - return new Guid(secuentialGuid); - } - } -} diff --git a/src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs b/src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs deleted file mode 100644 index 43b377183..000000000 --- a/src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using System.Reflection; - -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork -{ - /// - /// Base class for value objects in domain. - /// Value - /// - /// The type of this value object - public class ValueObject : IEquatable - where TValueObject : ValueObject - { - //A ValueObject doesn't have Identity, but we just need an Id/key so EF knows how to persist - //becuase in EF Core it still doesn't support ValueObjects or ComplexTypes - //This should be changed when EF Core supports any of those. - // https://github.com/aspnet/EntityFramework/issues/246 - public virtual Guid Id { get; protected set; } - - //IEquatable and Override Equals operators - - /// - /// - /// - /// - /// - public bool Equals(TValueObject other) - { - if ((object)other == null) - return false; - - if (Object.ReferenceEquals(this, other)) - return true; - - //compare all public properties - PropertyInfo[] publicProperties = this.GetType().GetProperties(); - - if ((object)publicProperties != null - && - publicProperties.Any()) - { - return publicProperties.All(p => - { - var left = p.GetValue(this, null); - var right = p.GetValue(other, null); - - - if (typeof(TValueObject).IsAssignableFrom(left.GetType())) - { - //check not self-references... - return Object.ReferenceEquals(left, right); - } - else - return left.Equals(right); - - - }); - } - else - return true; - } - /// - /// - /// - /// - /// - public override bool Equals(object obj) - { - if ((object)obj == null) - return false; - - if (Object.ReferenceEquals(this, obj)) - return true; - - ValueObject item = obj as ValueObject; - - if ((object)item != null) - return Equals((TValueObject)item); - else - return false; - - } - /// - /// - /// - /// - public override int GetHashCode() - { - int hashCode = 31; - bool changeMultiplier = false; - int index = 1; - - //compare all public properties - PropertyInfo[] publicProperties = this.GetType().GetProperties(); - - - if ((object)publicProperties != null - && - publicProperties.Any()) - { - foreach (var item in publicProperties) - { - object value = item.GetValue(this, null); - - if ((object)value != null) - { - - hashCode = hashCode * ((changeMultiplier) ? 59 : 114) + value.GetHashCode(); - - changeMultiplier = !changeMultiplier; - } - else - hashCode = hashCode ^ (index * 13);//only for support {"a",null,null,"a"} <> {null,"a","a",null} - } - } - - return hashCode; - } - /// - /// - /// - /// - /// - /// - public static bool operator ==(ValueObject left, ValueObject right) - { - if (Object.Equals(left, null)) - return (Object.Equals(right, null)) ? true : false; - else - return left.Equals(right); - - } - /// - /// - /// - /// - /// - /// - public static bool operator !=(ValueObject left, ValueObject right) - { - return !(left == right); - } - - - } -} - diff --git a/src/Services/Ordering/Ordering.Domain/project.json b/src/Services/Ordering/Ordering.Domain/project.json index bcfd892ef..db56591f2 100644 --- a/src/Services/Ordering/Ordering.Domain/project.json +++ b/src/Services/Ordering/Ordering.Domain/project.json @@ -2,9 +2,7 @@ "version": "1.0.0-*", "dependencies": { - "NETStandard.Library": "1.6.0", - "System.Reflection.TypeExtensions": "4.1.0", - "System.Runtime.Serialization.Primitives": "4.1.1" + "NETStandard.Library": "1.6" }, "frameworks": { diff --git a/test/Services/Ordering.Test/Ordering.Test.xproj b/src/Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.xproj similarity index 68% rename from test/Services/Ordering.Test/Ordering.Test.xproj rename to src/Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.xproj index 7fa7f1968..21d5cdd3f 100644 --- a/test/Services/Ordering.Test/Ordering.Test.xproj +++ b/src/Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.xproj @@ -1,21 +1,19 @@  - + - 14.0.25420 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - a0afc432-3846-4b4e-bd8e-3c8c896f4967 - Ordering.Test + 95f1f07c-4d92-4742-bd07-e5b805aab651 + Microsoft.eShopOnContainers.Services.Ordering.Infrastructure .\obj .\bin\ + v4.5.1 2.0 - - - \ No newline at end of file diff --git a/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs b/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs new file mode 100644 index 000000000..9be6d29d5 --- /dev/null +++ b/src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs @@ -0,0 +1,180 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure +{ + using System; + using System.Threading.Tasks; + using Domain.SeedWork; + using EntityFrameworkCore.Metadata; + using Microsoft.EntityFrameworkCore; + using Microsoft.EntityFrameworkCore.Metadata.Builders; + using Microsoft.eShopOnContainers.Services.Ordering.Domain; + + public class OrderingContext + : DbContext,IUnitOfWork + + { + const string DEFAULT_SCHEMA = "ordering"; + + public DbSet Orders { get; set; } + + public DbSet OrderItems { get; set; } + + public DbSet Payments { get; set; } + + public DbSet Buyers { get; set; } + + public DbSet CardTypes { get; set; } + + public DbSet OrderStatus { get; set; } + + public DbSet
Addresses { get; set; } + + public OrderingContext(DbContextOptions options) : base(options) { } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(ConfigureBuyer); + modelBuilder.Entity(ConfigurePayment); + modelBuilder.Entity(ConfigureOrder); + modelBuilder.Entity(ConfigureOrderItems); + modelBuilder.Entity(ConfigureCardTypes); + modelBuilder.Entity(ConfigureOrderStatus); + modelBuilder.Entity
(ConfigureAddress); + + modelBuilder.Entity
() + .ToTable("address", DEFAULT_SCHEMA); + } + + + + void ConfigureBuyer(EntityTypeBuilder buyerConfiguration) + { + buyerConfiguration.ToTable("buyers", DEFAULT_SCHEMA); + + buyerConfiguration.HasIndex(b => b.FullName) + .IsUnique(true); + + buyerConfiguration.HasKey(b => b.Id); + + buyerConfiguration.Property(b => b.Id) + .ForSqlServerUseSequenceHiLo("buyerseq", DEFAULT_SCHEMA); + + buyerConfiguration.Property(b => b.FullName) + .HasMaxLength(200) + .IsRequired(); + + buyerConfiguration.HasMany(b => b.Payments) + .WithOne() + .HasForeignKey(p => p.BuyerId) + .OnDelete(DeleteBehavior.Cascade); + } + + void ConfigurePayment(EntityTypeBuilder paymentConfiguration) + { + paymentConfiguration.ToTable("payments", DEFAULT_SCHEMA); + + paymentConfiguration.HasKey(b => b.Id); + + paymentConfiguration.Property(b => b.Id) + .ForSqlServerUseSequenceHiLo("paymentseq", DEFAULT_SCHEMA); + + paymentConfiguration.Property(p => p.CardHolderName) + .HasMaxLength(200) + .IsRequired(); + + paymentConfiguration.Property(p => p.CardNumber) + .HasMaxLength(25) + .IsRequired(); + + paymentConfiguration.Property(p => p.Expiration) + .IsRequired(); + + paymentConfiguration.HasOne(p => p.CardType) + .WithMany() + .HasForeignKey(p => p.CardTypeId); + } + + void ConfigureOrder(EntityTypeBuilder orderConfiguration) + { + orderConfiguration.ToTable("orders", DEFAULT_SCHEMA); + + orderConfiguration.HasKey(o => o.Id); + + orderConfiguration.Property(o => o.Id) + .ForSqlServerUseSequenceHiLo("orderseq", DEFAULT_SCHEMA); + + orderConfiguration.Property(o => o.OrderDate) + .IsRequired(); + + orderConfiguration.HasOne(o => o.Payment) + .WithMany() + .HasForeignKey(o => o.PaymentId) + .OnDelete(DeleteBehavior.Restrict); + + orderConfiguration.HasOne(o => o.Buyer) + .WithMany() + .HasForeignKey(o => o.BuyerId); + + orderConfiguration.HasOne(o => o.Status) + .WithMany() + .HasForeignKey(o => o.StatusId); + } + + void ConfigureOrderItems(EntityTypeBuilder orderItemConfiguration) + { + orderItemConfiguration.ToTable("orderItems", DEFAULT_SCHEMA); + + orderItemConfiguration.HasKey(o => o.Id); + + orderItemConfiguration.Property(o => o.Discount) + .IsRequired(); + + orderItemConfiguration.Property(o => o.ProductId) + .IsRequired(); + + orderItemConfiguration.Property(o => o.ProductName) + .IsRequired(); + + orderItemConfiguration.Property(o => o.UnitPrice) + .IsRequired(); + + orderItemConfiguration.Property(o => o.Units) + .ForSqlServerHasDefaultValue(1) + .IsRequired(); + } + + void ConfigureOrderStatus(EntityTypeBuilder orderStatusConfiguration) + { + orderStatusConfiguration.ToTable("orderstatus", DEFAULT_SCHEMA); + + orderStatusConfiguration.HasKey(o => o.Id); + + orderStatusConfiguration.Property(o => o.Id) + .HasDefaultValue(1) + .IsRequired(); + + orderStatusConfiguration.Property(o => o.Name) + .HasMaxLength(200) + .IsRequired(); + } + + void ConfigureCardTypes(EntityTypeBuilder cardTypesConfiguration) + { + cardTypesConfiguration.ToTable("cardtypes", DEFAULT_SCHEMA); + + cardTypesConfiguration.HasKey(ct => ct.Id); + + cardTypesConfiguration.Property(ct => ct.Id) + .HasDefaultValue(1) + .IsRequired(); + + cardTypesConfiguration.Property(ct => ct.Name) + .HasMaxLength(200) + .IsRequired(); + } + + void ConfigureAddress(EntityTypeBuilder
addressConfiguration) + { + addressConfiguration.ToTable("address", DEFAULT_SCHEMA); + } + } +} diff --git a/src/Services/Ordering/Ordering.Infrastructure/Properties/AssemblyInfo.cs b/src/Services/Ordering/Ordering.Infrastructure/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..00732b2ad --- /dev/null +++ b/src/Services/Ordering/Ordering.Infrastructure/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ordering.Infrastructure")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("95f1f07c-4d92-4742-bd07-e5b805aab651")] diff --git a/src/Services/Ordering/Ordering.Infrastructure/Repositories/BuyerRepository.cs b/src/Services/Ordering/Ordering.Infrastructure/Repositories/BuyerRepository.cs new file mode 100644 index 000000000..3a1f75c0d --- /dev/null +++ b/src/Services/Ordering/Ordering.Infrastructure/Repositories/BuyerRepository.cs @@ -0,0 +1,51 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories +{ + using Domain.SeedWork; + using Microsoft.EntityFrameworkCore; + using Microsoft.eShopOnContainers.Services.Ordering.Domain; + using Microsoft.eShopOnContainers.Services.Ordering.Domain.Repositories; + using System; + using System.Linq; + using System.Threading.Tasks; + + public class BuyerRepository + : IBuyerRepository + { + private readonly OrderingContext _context; + + public BuyerRepository(OrderingContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + _context = context; + } + + public IUnitOfWork UnitOfWork + { + get + { + return _context; + } + } + + public Buyer Add(Buyer buyer) + { + return _context.Buyers + .Add(buyer) + .Entity; + } + + public async Task FindAsync(string name) + { + var buyer = await _context.Buyers + .Include(b => b.Payments) + .Where(b => b.FullName == name) + .SingleOrDefaultAsync(); + + return buyer; + } + } +} diff --git a/src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs b/src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs new file mode 100644 index 000000000..94f48d9aa --- /dev/null +++ b/src/Services/Ordering/Ordering.Infrastructure/Repositories/OrderRepository.cs @@ -0,0 +1,36 @@ +namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Repositories +{ + using Domain; + using Domain.SeedWork; + using Microsoft.eShopOnContainers.Services.Ordering.Domain.Repositories; + using System; + + public class OrderRepository + : IOrderRepository + { + private readonly OrderingContext _context; + public IUnitOfWork UnitOfWork + { + get + { + return _context; + } + } + + public OrderRepository(OrderingContext context) + { + if (context == null) + { + throw new ArgumentNullException(nameof(context)); + } + + _context = context; + } + + public Order Add(Order order) + { + return _context.Orders.Add(order) + .Entity; + } + } +} diff --git a/src/Services/Ordering/Ordering.Infrastructure/project.json b/src/Services/Ordering/Ordering.Infrastructure/project.json new file mode 100644 index 000000000..03c2eeef4 --- /dev/null +++ b/src/Services/Ordering/Ordering.Infrastructure/project.json @@ -0,0 +1,16 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "NETStandard.Library": "1.6.0", + "Microsoft.EntityFrameworkCore": "1.0.1", + "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1", + "Ordering.Domain": "1.0.0-*" + }, + + "frameworks": { + "netstandard1.6": { + "imports": "dnxcore50" + } + } +} diff --git a/src/Services/Ordering/Ordering.SqlData/Queries/IOrderdingQueries.cs b/src/Services/Ordering/Ordering.SqlData/Queries/IOrderdingQueries.cs deleted file mode 100644 index 783cf7a47..000000000 --- a/src/Services/Ordering/Ordering.SqlData/Queries/IOrderdingQueries.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries -{ - //The OrderingQueries Contracts/Interfaces could be moved to a third assembly - //We're not putting this contract in the Domain layer assembly because - //queries/joins are just Application's needs and should not be limited - //to the Domain Model restrictions (Aggregates and Repositories restrictions). - // - //In this case we're using the same EF Context but another good approach - //is also to simply use SQL sentences for the queries with any Micro-ORM (like Dapper) or even just ADO.NET - // - //The point is that Queries are IDEMPOTENT and don't need to commit to DDD Domain restrictions - //so could be implemented in a completely orthogonal way in regards the Domain Layer (à la CQRS) - - public interface IOrderdingQueries - { - Task GetAllOrdersIncludingValueObjectsAndChildEntities(); - Task GetOrderById(Guid orderId); - } -} diff --git a/src/Services/Ordering/Ordering.SqlData/Queries/OrderingQueries.cs b/src/Services/Ordering/Ordering.SqlData/Queries/OrderingQueries.cs deleted file mode 100644 index c097acd82..000000000 --- a/src/Services/Ordering/Ordering.SqlData/Queries/OrderingQueries.cs +++ /dev/null @@ -1,98 +0,0 @@ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -using Microsoft.EntityFrameworkCore; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries -{ - //In this case, for the Application queries, we're using the same EF Context but another good approach - //is also to simply use SQL sentences for the queries with any Micro-ORM (like Dapper) or even just ADO.NET - // - //The point is that Queries are IDEMPOTENT and don't need to commit to DDD Domain restrictions - //so could be implemented in a completely orthogonal way in regards the Domain Layer (à la CQRS) - - public class OrderingQueries : IOrderdingQueries - { - private OrderingDbContext _dbContext; - - public OrderingQueries(OrderingDbContext orderingDbContext) - { - _dbContext = orderingDbContext; - } - - public async Task GetAllOrdersIncludingValueObjectsAndChildEntities() - { - var orders = await _dbContext.Orders - .Include(o => o.ShippingAddress) - .Include(o => o.BillingAddress) - .Include(o => o.OrderItems) - .ToListAsync(); - - // Dynamically generated a Response-Model that includes only the fields you need in the response. - // This keeps the JSON response minimal. - // Could also use var - dynamic response = orders.Select(o => new - { - id = o.Id, - orderNumber = o.OrderNumber, - buyerId = o.BuyerId, - orderDate = o.OrderDate, - status = o.Status, - shippingAddress = o.ShippingAddress, - billingAddress = o.BillingAddress, - orderItems = o.OrderItems.Select(i => new - { - id = i.Id, - productId = i.ProductId, - unitPrice = i.UnitPrice, - quantity = i.Quantity, - discount = i.Discount - } - ) - }); - - return response; - } - - public async Task GetOrderById(Guid orderId) - { - var order = await _dbContext.Orders - .Include(o => o.ShippingAddress) - .Include(o => o.BillingAddress) - .Include(o => o.OrderItems) - .Where(o => o.Id == orderId) - .SingleOrDefaultAsync(); - - // Dynamically generated a Response-Model that includes only the fields you need in the response. - // This keeps the JSON response minimal. - // Could also use var - dynamic response = new - { - id = order.Id, - orderNumber = order.OrderNumber, - buyerId = order.BuyerId, - orderDate = order.OrderDate, - status = order.Status, - shippingAddress = order.ShippingAddress, - billingAddress = order.BillingAddress, - orderItems = order.OrderItems.Select(i => new - { - id = i.Id, - productId = i.ProductId, - unitPrice = i.UnitPrice, - quantity = i.Quantity, - discount = i.Discount - } - ) - }; - - return response; - } - } -} diff --git a/src/Services/Ordering/Ordering.SqlData/Repositories/OrderRepository.cs b/src/Services/Ordering/Ordering.SqlData/Repositories/OrderRepository.cs deleted file mode 100644 index 7c8140d06..000000000 --- a/src/Services/Ordering/Ordering.SqlData/Repositories/OrderRepository.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; -using Microsoft.EntityFrameworkCore; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SqlData.Repositories -{ - //1:1 relationship between Repository and Aggregate (i.e. OrderRepository and Order) - public class OrderRepository : IOrderRepository - { - private readonly OrderingDbContext _context; - - public IUnitOfWork UnitOfWork => _context; - - public OrderRepository(OrderingDbContext orderingDbContext) - { - _context = orderingDbContext; - } - - public void Add(Order order) - { - _context.Orders.Add(order); - } - - public void Update(Order order) - { - _context.Orders.Update(order); - } - - public async Task Remove(Guid orderId) - { - var orderToRemove = await _context.Orders.Where(o => o.Id == orderId).SingleOrDefaultAsync(); - _context.Orders.Remove(orderToRemove); - } - - public async Task FindAsync(Guid id) - { - if (id != Guid.Empty) - return await _context.Set().FirstOrDefaultAsync(o => o.Id == id); - else - return null; - } - } - -} diff --git a/src/Services/Ordering/Ordering.SqlData/UnitOfWork/DBContextUtil.cs b/src/Services/Ordering/Ordering.SqlData/UnitOfWork/DBContextUtil.cs deleted file mode 100644 index 3672653f2..000000000 --- a/src/Services/Ordering/Ordering.SqlData/UnitOfWork/DBContextUtil.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork -{ - public class DbContextUtil - { - public static DbContextOptions CreateNewContextOptionsForInMemoryDB() - { - // Create a fresh service provider, and therefore a fresh - // InMemory database instance. - var serviceProvider = new ServiceCollection() - .AddEntityFrameworkInMemoryDatabase() - .BuildServiceProvider(); - - // Create a new options instance telling the context to use an - // InMemory database and the new service provider. - var builder = new DbContextOptionsBuilder(); - builder.UseInMemoryDatabase() - .UseInternalServiceProvider(serviceProvider); - - return builder.Options; - } - - public static DbContextOptions CreateNewContextOptionsForSqlDb() - { - // Create a new options instance telling the context to use a Sql database - var builder = new DbContextOptionsBuilder(); - - //SQL LocalDB - //var connString = @"Server=(localdb)\mssqllocaldb;Database=Microsoft.eShopOnContainers.Services.OrderingDb;Trusted_Connection=True;"; - - //SQL SERVER on-premises - - //(Integrated Security) var connString = @"Server=CESARDLBOOKVHD;Database=Microsoft.eShopOnContainers.Services.OrderingDb;Trusted_Connection=True;"; - - //(SQL Server Authentication) - var connString = @"Server=10.0.75.1;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;"; - - //SQL LOCALDB - builder.UseSqlServer(connString); - - return builder.Options; - } - } -} diff --git a/src/Services/Ordering/Ordering.SqlData/UnitOfWork/OrderingDbContext.cs b/src/Services/Ordering/Ordering.SqlData/UnitOfWork/OrderingDbContext.cs deleted file mode 100644 index e35c3e540..000000000 --- a/src/Services/Ordering/Ordering.SqlData/UnitOfWork/OrderingDbContext.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; - -namespace Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork -{ - public class OrderingDbContext : DbContext, IUnitOfWork - { - public OrderingDbContext(DbContextOptions options) - : base(options) - { } - - public DbSet Orders { get; set; } - - //(CDLTLL) - /* - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - //If running from ASP.NET Core, config is done at StartUp.cs --> ConfigureServices() outside - //and injected through DI later on. The following config is used when running Tests or similar contexts - if (!optionsBuilder.IsConfigured) - { - //SQL LocalDB - //var connString = @"Server=(localdb)\mssqllocaldb;Database=Microsoft.eShopOnContainers.Services.OrderingDb;Trusted_Connection=True;"; - - //SQL SERVER on-premises - - //(Integrated Security) - //var connString = @"Server=CESARDLBOOKVHD;Database=Microsoft.eShopOnContainers.Services.OrderingDb;Trusted_Connection=True;"; - - //(SQL Server Authentication) - var connString = @"Server=10.0.75.1;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;"; - - //SQL LOCALDB - optionsBuilder.UseSqlServer(connString); - - } - } - */ - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - // Add your customizations after calling base.OnModelCreating(builder); - - //Sequence to be used as part of the OrderNumber - modelBuilder.HasSequence("OrderSequences", schema: "shared") - .StartsAt(1001) - .IncrementsBy(1); - - modelBuilder.Entity() - .Property(o => o.SequenceNumber) - .HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); - - } - - public async Task CommitAsync() - { - int changes = 0; - - try - { - //(CDLTLL) TBD - //RemoveOrphanedChilds(); - - changes = await base.SaveChangesAsync(); - } - catch (Exception ex) - { - //(CDLTLL) TBD - //RejectChanges(); - throw ex; - } - - return changes; - } - } -} diff --git a/src/Services/Ordering/Ordering.SqlData/project.json b/src/Services/Ordering/Ordering.SqlData/project.json deleted file mode 100644 index 8ede54bb4..000000000 --- a/src/Services/Ordering/Ordering.SqlData/project.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "Microsoft.EntityFrameworkCore": "1.0.0", - "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", - "NETStandard.Library": "1.6.0", - "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0", - "Ordering.Domain": "1.0.0-*", - "Microsoft.EntityFrameworkCore.InMemory": "1.0.0" - }, - - "frameworks": { - "netstandard1.6": { - "imports": [ "dnxcore50", "portable-net451+win8" ] - } - - } -} diff --git a/test/Services/Ordering.TestsOLD/Ordering.Tests.xproj b/test/Services/FunctionalTests/FunctionalTests.xproj similarity index 84% rename from test/Services/Ordering.TestsOLD/Ordering.Tests.xproj rename to test/Services/FunctionalTests/FunctionalTests.xproj index 80f992088..4851c130c 100644 --- a/test/Services/Ordering.TestsOLD/Ordering.Tests.xproj +++ b/test/Services/FunctionalTests/FunctionalTests.xproj @@ -7,11 +7,11 @@ - 9b26282e-d550-4289-9a18-3334023c4f69 - Ordering.Tests + 621e7211-58d0-45fd-9600-1cb490bd930e + FunctionalTests .\obj .\bin\ - v4.6 + v4.5.1 diff --git a/test/Services/Ordering.TestsOLD/Properties/AssemblyInfo.cs b/test/Services/FunctionalTests/Properties/AssemblyInfo.cs similarity index 87% rename from test/Services/Ordering.TestsOLD/Properties/AssemblyInfo.cs rename to test/Services/FunctionalTests/Properties/AssemblyInfo.cs index c6794bc99..2adf86bca 100644 --- a/test/Services/Ordering.TestsOLD/Properties/AssemblyInfo.cs +++ b/test/Services/FunctionalTests/Properties/AssemblyInfo.cs @@ -7,7 +7,7 @@ using System.Runtime.InteropServices; // associated with an assembly. [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Ordering.Tests")] +[assembly: AssemblyProduct("FunctionalTests")] [assembly: AssemblyTrademark("")] // Setting ComVisible to false makes the types in this assembly not visible @@ -16,4 +16,4 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9b26282e-d550-4289-9a18-3334023c4f69")] +[assembly: Guid("621e7211-58d0-45fd-9600-1cb490bd930e")] diff --git a/test/Services/Ordering.TestsOLD/project.json b/test/Services/FunctionalTests/project.json similarity index 97% rename from test/Services/Ordering.TestsOLD/project.json rename to test/Services/FunctionalTests/project.json index 9a71f253f..864b9a5f3 100644 --- a/test/Services/Ordering.TestsOLD/project.json +++ b/test/Services/FunctionalTests/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { diff --git a/test/Services/Ordering.Test/DataIntegrationTests.cs b/test/Services/Ordering.Test/DataIntegrationTests.cs deleted file mode 100644 index ff0c93f65..000000000 --- a/test/Services/Ordering.Test/DataIntegrationTests.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Linq; -using Xunit; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; -using Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts; -using Microsoft.eShopOnContainers.Services.Ordering.SqlData.Repositories; -using Microsoft.EntityFrameworkCore; - -namespace DataIntegrationTests -{ - //Basic documentation for Testing EF Core classes - // http://ef.readthedocs.io/en/latest/miscellaneous/testing.html - public class Tests - { - [Fact] - public async void Add_order_to_data_model() - { - // All contexts that share the same service provider will share the same database - - //Using InMemory DB - //var options = DbContextUtil.CreateNewContextOptionsForInMemoryDB(); - - //Using Sql Server - var options = DbContextUtil.CreateNewContextOptionsForSqlDb(); - - // Run the test against one instance of the context - using (var context = new OrderingDbContext(options)) - { - IOrderRepository orderRepository = new OrderRepository(context); - - //Create generic Address ValueObject - Address sampleAddress = new Address("15703 NE 61st Ct.", - "Redmond", - "Washington", - "WA", - "United States", - "US", - "98052", - 47.661492, - -122.131309 - ); - //Create sample Orders - Order order1 = new Order(Guid.NewGuid(), sampleAddress, sampleAddress); - - //Add a few OrderItems - order1.AddNewOrderItem(Guid.NewGuid(), 2, 25, 30); - order1.AddNewOrderItem(Guid.NewGuid(), 1, 58, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 1, 60, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 3, 12, 0); - order1.AddNewOrderItem(Guid.NewGuid(), 5, 3, 0); - - orderRepository.Add(order1); - int numChanges = await orderRepository.UnitOfWork.CommitAsync(); - - //With no Async Repository - //context.Orders.Add(order1); - //context.SaveChanges(); - - } - - //// Use a separate instance of the context to verify correct data was saved to database - using (var context = new OrderingDbContext(options)) - { - var orders = context.Orders - .Include(o => o.ShippingAddress) - .Include(o => o.BillingAddress) - .ToList(); - //Could be using .Load() if you don't want to create a List - - //OTHER SAMPLE - //var company = context.Companies - // .Include(co => co.Employees).ThenInclude(emp => emp.Employee_Car) - // .Include(co => co.Employees).ThenInclude(emp => emp.Employee_Country) - // .FirstOrDefault(co => co.companyID == companyID); - - //Assert when running test with a clean In-Memory DB - //Assert.Equal(1, context.Orders.Count()); - - string cityName = orders.First().ShippingAddress.City; - Assert.Equal("Redmond", cityName); - } - } - - } -} diff --git a/test/Services/Ordering.Test/project.json b/test/Services/Ordering.Test/project.json deleted file mode 100644 index ab108e9cd..000000000 --- a/test/Services/Ordering.Test/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "1.0.0-*", - "buildOptions": { - "debugType": "portable" - }, - "dependencies": { - "System.Runtime.Serialization.Primitives": "4.1.1", - "xunit": "2.1.0", - "dotnet-test-xunit": "2.2.0-preview2-build1029", - "Ordering.Domain": "1.0.0-*", - "Ordering.SqlData": "1.0.0-*", - "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", - "Microsoft.EntityFrameworkCore.InMemory": "1.0.0" - }, - "testRunner": "xunit", - "frameworks": { - "netcoreapp1.0": { - "dependencies": { - "Microsoft.NETCore.App": { - "type": "platform", - "version": "1.0.0" - } - }, - "imports": [ - "dotnet5.4", - "portable-net451+win8" - ] - } - } -}