Browse Source

More iteration on Ordering Refactoring

pull/49/merge
Unai 8 years ago
parent
commit
1ae4d01f82
29 changed files with 1172 additions and 489 deletions
  1. +51
    -32
      eShopOnContainers.sln
  2. +1
    -1
      global.json
  3. +44
    -44
      src/Console/eShopConsole/Program.cs
  4. +0
    -2
      src/Console/eShopConsole/project.json
  5. +2
    -1
      src/Services/Catalog/Catalog.API/project.json
  6. +227
    -0
      src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161122162602_initial.Designer.cs
  7. +282
    -0
      src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161122162602_initial.cs
  8. +226
    -0
      src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs
  9. +26
    -0
      src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs
  10. +11
    -8
      src/Services/Ordering/Ordering.API/Startup.cs
  11. +12
    -12
      src/Services/Ordering/Ordering.API/project.json
  12. +1
    -1
      src/Services/Ordering/Ordering.API/settings.json
  13. +1
    -1
      src/Services/Ordering/Ordering.Application/Commands/NewOrderREquestHandler.cs
  14. +31
    -6
      src/Services/Ordering/Ordering.Application/Queries/OrderQueries.cs
  15. +4
    -1
      src/Services/Ordering/Ordering.Application/project.json
  16. +57
    -0
      src/Services/Ordering/Ordering.Domain/CardType.cs
  17. +8
    -2
      src/Services/Ordering/Ordering.Domain/Order.cs
  18. +27
    -0
      src/Services/Ordering/Ordering.Domain/Payment.cs
  19. +0
    -126
      src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs
  20. +1
    -3
      src/Services/Ordering/Ordering.Domain/project.json
  21. +3
    -3
      src/Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.xproj
  22. +138
    -0
      src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs
  23. +2
    -2
      src/Services/Ordering/Ordering.Infrastructure/Properties/AssemblyInfo.cs
  24. +16
    -0
      src/Services/Ordering/Ordering.Infrastructure/project.json
  25. +0
    -50
      src/Services/Ordering/Ordering.SqlData/UnitOfWork/DBContextUtil.cs
  26. +0
    -82
      src/Services/Ordering/Ordering.SqlData/UnitOfWork/OrderingDbContext.cs
  27. +0
    -19
      src/Services/Ordering/Ordering.SqlData/project.json
  28. +0
    -86
      test/Services/Ordering.Test/DataIntegrationTests.cs
  29. +1
    -7
      test/Services/Ordering.Test/project.json

+ 51
- 32
eShopOnContainers.sln View File

@ -38,10 +38,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{EF
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}"
@ -60,6 +56,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "eShopOnContainers.WebSPA",
EndProject
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
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@ -218,32 +216,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
@ -578,6 +550,54 @@ Global
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -595,8 +615,6 @@ Global
{F5598DCB-6DDE-4661-AD9D-A55612DA7E76} = {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}
@ -606,5 +624,6 @@ Global
{9CC7814B-72A6-465B-A61C-57B512DEE303} = {F61357CE-1CC2-410E-8776-B16EEBC98EB8}
{9842DB3A-1391-48C7-A49C-2FABD0A18AC2} = {E279BF0F-7F66-4F3A-A3AB-2CDA66C1CD04}
{4193CAA3-A1C3-4818-A06F-A2D85FDE77E7} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B}
{95F1F07C-4D92-4742-BD07-E5B805AAB651} = {0BD0DB92-2D98-44D9-9AC0-C59186D59B0B}
EndGlobalSection
EndGlobal

+ 1
- 1
global.json View File

@ -7,6 +7,6 @@
],
"sdk": {
"version": "1.0.0-preview2-003121"
"version": "1.0.0-preview2-003131"
}
}

+ 44
- 44
src/Console/eShopConsole/Program.cs View File

@ -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<Order>().ShippingAddress.City;
Console.WriteLine("City name retreived from SQL Server: "+cityName);
}
// string cityName = orders.First<Order>().ShippingAddress.City;
// Console.WriteLine("City name retreived from SQL Server: "+cityName);
//}
}
}
}

+ 0
- 2
src/Console/eShopConsole/project.json View File

@ -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": {


+ 2
- 1
src/Services/Catalog/Catalog.API/project.json View File

@ -54,5 +54,6 @@
"Dockerfile"
]
},
"scripts": {}
"scripts": {},
"userSecretsId": "aspnet-Catalog.API-20161122013618"
}

+ 227
- 0
src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161122162602_initial.Designer.cs View File

@ -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("20161122162602_initial")]
partial class initial
{
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<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("City");
b.Property<string>("Country");
b.Property<string>("CountryCode");
b.Property<double>("Latitude");
b.Property<double>("Longitude");
b.Property<string>("State");
b.Property<string>("StateCode");
b.Property<string>("Street");
b.Property<string>("ZipCode");
b.HasKey("Id");
b.ToTable("address","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Buyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "buyerseq")
.HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("FullName")
.IsRequired()
.HasAnnotation("MaxLength", 200);
b.HasKey("Id");
b.ToTable("buyers","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.CardType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("Id");
b.ToTable("cardtypes","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "orderseq")
.HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<int?>("BillingAddressId");
b.Property<int>("BuyerId");
b.Property<DateTime>("OrderDate");
b.Property<int>("PaymentId");
b.Property<int?>("ShippingAddressId");
b.Property<int>("StatusId");
b.HasKey("Id");
b.HasIndex("BillingAddressId");
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<int>("Id")
.ValueGeneratedOnAdd();
b.Property<decimal>("Discount");
b.Property<int>("OrderId");
b.Property<int>("ProductId");
b.Property<string>("ProductName")
.IsRequired();
b.Property<decimal>("UnitPrice");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("Id");
b.ToTable("orderstatus","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Payment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "paymentseq")
.HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("CardHolderName")
.IsRequired()
.HasAnnotation("MaxLength", 200);
b.Property<string>("CardNumber")
.IsRequired()
.HasAnnotation("MaxLength", 25);
b.Property<int>("CardTypeId");
b.Property<DateTime>("Expiration");
b.Property<string>("SecurityNumber");
b.HasKey("Id");
b.HasIndex("CardTypeId");
b.ToTable("payments","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order", b =>
{
b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Address", "BillingAddress")
.WithMany()
.HasForeignKey("BillingAddressId")
.OnDelete(DeleteBehavior.SetNull);
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")
.OnDelete(DeleteBehavior.Cascade);
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.CardType", "CardType")
.WithMany()
.HasForeignKey("CardTypeId")
.OnDelete(DeleteBehavior.Cascade);
});
}
}
}

+ 282
- 0
src/Services/Ordering/Ordering.API/Infrastructure/Migrations/20161122162602_initial.cs View File

@ -0,0 +1,282 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Metadata;
namespace Ordering.API.Infrastructure.Migrations
{
public partial class initial : 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<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
City = table.Column<string>(nullable: true),
Country = table.Column<string>(nullable: true),
CountryCode = table.Column<string>(nullable: true),
Latitude = table.Column<double>(nullable: false),
Longitude = table.Column<double>(nullable: false),
State = table.Column<string>(nullable: true),
StateCode = table.Column<string>(nullable: true),
Street = table.Column<string>(nullable: true),
ZipCode = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_address", x => x.Id);
});
migrationBuilder.CreateTable(
name: "buyers",
schema: "ordering",
columns: table => new
{
Id = table.Column<int>(nullable: false),
FullName = table.Column<string>(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<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_cardtypes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "orderstatus",
schema: "ordering",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_orderstatus", x => x.Id);
});
migrationBuilder.CreateTable(
name: "payments",
schema: "ordering",
columns: table => new
{
Id = table.Column<int>(nullable: false),
CardHolderName = table.Column<string>(maxLength: 200, nullable: false),
CardNumber = table.Column<string>(maxLength: 25, nullable: false),
CardTypeId = table.Column<int>(nullable: false),
Expiration = table.Column<DateTime>(nullable: false),
SecurityNumber = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_payments", x => x.Id);
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<int>(nullable: false),
BillingAddressId = table.Column<int>(nullable: true),
BuyerId = table.Column<int>(nullable: false),
OrderDate = table.Column<DateTime>(nullable: false),
PaymentId = table.Column<int>(nullable: false),
ShippingAddressId = table.Column<int>(nullable: true),
StatusId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_orders", x => x.Id);
table.ForeignKey(
name: "FK_orders_address_BillingAddressId",
column: x => x.BillingAddressId,
principalSchema: "ordering",
principalTable: "address",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
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.Cascade);
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<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Discount = table.Column<decimal>(nullable: false),
OrderId = table.Column<int>(nullable: false),
ProductId = table.Column<int>(nullable: false),
ProductName = table.Column<string>(nullable: false),
UnitPrice = table.Column<decimal>(nullable: false),
Units = table.Column<int>(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_orders_BillingAddressId",
schema: "ordering",
table: "orders",
column: "BillingAddressId");
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_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: "address",
schema: "ordering");
migrationBuilder.DropTable(
name: "buyers",
schema: "ordering");
migrationBuilder.DropTable(
name: "payments",
schema: "ordering");
migrationBuilder.DropTable(
name: "orderstatus",
schema: "ordering");
migrationBuilder.DropTable(
name: "cardtypes",
schema: "ordering");
}
}
}

+ 226
- 0
src/Services/Ordering/Ordering.API/Infrastructure/Migrations/OrderingContextModelSnapshot.cs View File

@ -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<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("City");
b.Property<string>("Country");
b.Property<string>("CountryCode");
b.Property<double>("Latitude");
b.Property<double>("Longitude");
b.Property<string>("State");
b.Property<string>("StateCode");
b.Property<string>("Street");
b.Property<string>("ZipCode");
b.HasKey("Id");
b.ToTable("address","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Buyer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "buyerseq")
.HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("FullName")
.IsRequired()
.HasAnnotation("MaxLength", 200);
b.HasKey("Id");
b.ToTable("buyers","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.CardType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("Id");
b.ToTable("cardtypes","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "orderseq")
.HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<int?>("BillingAddressId");
b.Property<int>("BuyerId");
b.Property<DateTime>("OrderDate");
b.Property<int>("PaymentId");
b.Property<int?>("ShippingAddressId");
b.Property<int>("StatusId");
b.HasKey("Id");
b.HasIndex("BillingAddressId");
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<int>("Id")
.ValueGeneratedOnAdd();
b.Property<decimal>("Discount");
b.Property<int>("OrderId");
b.Property<int>("ProductId");
b.Property<string>("ProductName")
.IsRequired();
b.Property<decimal>("UnitPrice");
b.Property<int>("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<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("Id");
b.ToTable("orderstatus","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Payment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasAnnotation("SqlServer:HiLoSequenceName", "paymentseq")
.HasAnnotation("SqlServer:HiLoSequenceSchema", "ordering")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.SequenceHiLo);
b.Property<string>("CardHolderName")
.IsRequired()
.HasAnnotation("MaxLength", 200);
b.Property<string>("CardNumber")
.IsRequired()
.HasAnnotation("MaxLength", 25);
b.Property<int>("CardTypeId");
b.Property<DateTime>("Expiration");
b.Property<string>("SecurityNumber");
b.HasKey("Id");
b.HasIndex("CardTypeId");
b.ToTable("payments","ordering");
});
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.Order", b =>
{
b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.Address", "BillingAddress")
.WithMany()
.HasForeignKey("BillingAddressId")
.OnDelete(DeleteBehavior.SetNull);
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")
.OnDelete(DeleteBehavior.Cascade);
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.CardType", "CardType")
.WithMany()
.HasForeignKey("CardTypeId")
.OnDelete(DeleteBehavior.Cascade);
});
}
}
}

+ 26
- 0
src/Services/Ordering/Ordering.API/Infrastructure/OrderingContextSeed.cs View File

@ -0,0 +1,26 @@

namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure
{
using AspNetCore.Builder;
using Microsoft.EntityFrameworkCore;
using Ordering.Infrastructure;
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();
await context.SaveChangesAsync();
}
}
}
}

+ 11
- 8
src/Services/Ordering/Ordering.API/Startup.cs View File

@ -7,6 +7,8 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Ordering.Infrastructure;
using System.Reflection;
public class Startup
{
@ -14,8 +16,8 @@
{
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())
{
@ -34,12 +36,13 @@
// Add framework services.
services.AddMvc();
//services.AddEntityFrameworkSqlServer()
// .AddDbContext<OrderingDbContext>(options =>
// {
// options.UseSqlServer(Configuration["ConnectionString"]);
// });
services.AddEntityFrameworkSqlServer()
.AddDbContext<OrderingContext>(options =>
{
options.UseSqlServer(Configuration["ConnectionString"],
sqlop=>sqlop.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name));
});
services.AddSwaggerGen();
services.ConfigureSwaggerGen(options =>
{


+ 12
- 12
src/Services/Ordering/Ordering.API/project.json View File

@ -1,11 +1,10 @@
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"version": "1.0.1",
"type": "platform"
},
"MediatR.Extensions.Microsoft.DependencyInjection": "1.0.1",
"Microsoft.Extensions.DependencyInjection": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
@ -13,20 +12,20 @@
"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",
"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",
"Ordering.Application": "1.0.0-*",
"Ordering.Domain": "1.0.0-*",
"Ordering.SqlData": "1.0.0-*",
"Swashbuckle": "6.0.0-beta902",
"MediatR": "2.1.0"
"MediatR": "2.1.0",
"Ordering.Domain": "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",
@ -68,5 +67,6 @@
"postpublish": [
"dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
]
}
},
"userSecretsId": "aspnet-Ordering.API-20161122013547"
}

+ 1
- 1
src/Services/Ordering/Ordering.API/settings.json View File

@ -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;"
}

+ 1
- 1
src/Services/Ordering/Ordering.Application/Commands/NewOrderREquestHandler.cs View File

@ -4,7 +4,7 @@
using System;
using System.Threading.Tasks;
public class NewOrderREquestHandler
public class NewOrderRequestHandler
: IAsyncRequestHandler<NewOrderRequest, bool>
{
public Task<bool> Handle(NewOrderRequest message)


+ 31
- 6
src/Services/Ordering/Ordering.Application/Queries/OrderQueries.cs View File

@ -1,13 +1,38 @@

namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Queries
namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Queries
{
using System;
using System.Collections.Generic;
using System.Linq;
using Dapper;
using Microsoft.Extensions.Configuration;
using System.Data.SqlClient;
using System.Threading.Tasks;
public class OrderQueries
:IOrderQueries
{
private string _connectionString = string.Empty;
public OrderQueries(IConfiguration configuration)
{
_connectionString = configuration["ConnectionString"];
}
public async Task<dynamic> GetOrder(int id)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
return await connection.QueryAsync<dynamic>("SELECT * FROM ordering.Orders where Id=@id",new { id });
}
}
public async Task<dynamic> GetPendingOrders()
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
return await connection.QueryAsync<dynamic>("SELECT * FROM ordering.Orders");
}
}
}
}

+ 4
- 1
src/Services/Ordering/Ordering.Application/project.json View File

@ -4,8 +4,11 @@
"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.CSharp": "4.0.1",
"Microsoft.Extensions.Configuration": "1.0.0",
"System.Data.SqlClient": "4.1.0"
},
"frameworks": {


+ 57
- 0
src/Services/Ordering/Ordering.Domain/CardType.cs View File

@ -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(1, "Visa");
public static CardType MasterCard = new CardType(1, "MasterCard");
public string Name { get; private set; }
protected CardType() { }
public CardType(int id, string name)
{
Id = id;
Name = name;
}
public static IEnumerable<CardType> 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;
}
}
}

+ 8
- 2
src/Services/Ordering/Ordering.Domain/Order.cs View File

@ -13,18 +13,24 @@
public DateTime OrderDate { get; private set; }
public int StatusId { get; private set; }
public OrderStatus Status { get; private set; }
public ICollection<OrderItem> OrderItems { get; set; }
public int ShippingAddressId { get; private set; }
public int? ShippingAddressId { get; private set; }
public Address ShippingAddress { get; private set; }
public int BillingAddressId { get; private set; }
public int? BillingAddressId { get; private set; }
public Address BillingAddress { get; private set; }
public int PaymentId { get; private set; }
public Payment Payment { get; private set; }
protected Order() { }
}
}

+ 27
- 0
src/Services/Ordering/Ordering.Domain/Payment.cs View File

@ -0,0 +1,27 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain
{
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
public class Payment
: Entity, IAggregateRoot
{
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() { }
}
}

+ 0
- 126
src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs View File

@ -1,126 +0,0 @@

namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Reflection;
public class ValueObject<TValueObject> : IEquatable<TValueObject>
where TValueObject : ValueObject<TValueObject>
{
//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<TValueObject> item = obj as ValueObject<TValueObject>;
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<TValueObject> left, ValueObject<TValueObject> right)
{
if (Object.Equals(left, null))
return (Object.Equals(right, null)) ? true : false;
else
return left.Equals(right);
}
public static bool operator !=(ValueObject<TValueObject> left, ValueObject<TValueObject> right)
{
return !(left == right);
}
}
}

+ 1
- 3
src/Services/Ordering/Ordering.Domain/project.json View File

@ -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": {


src/Services/Ordering/Ordering.SqlData/Ordering.SqlData.xproj → src/Services/Ordering/Ordering.Infrastructure/Ordering.Infrastructure.xproj View File

@ -6,11 +6,11 @@
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>5da6ef13-c7e0-4ec4-8599-a61c6ac2628d</ProjectGuid>
<RootNamespace>Microsoft.eShopOnContainers.Services.Ordering.SqlData</RootNamespace>
<ProjectGuid>95f1f07c-4d92-4742-bd07-e5b805aab651</ProjectGuid>
<RootNamespace>Microsoft.eShopOnContainers.Services.Ordering.Infrastructure</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>

+ 138
- 0
src/Services/Ordering/Ordering.Infrastructure/OrderingContext.cs View File

@ -0,0 +1,138 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.Infrastructure
{
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopOnContainers.Services.Ordering.Domain;
public class OrderingContext
: DbContext
{
const string DEFAULT_SCHEMA = "ordering";
public DbSet<Order> Orders { get; set; }
public DbSet<OrderItem> OrderItems { get; set; }
public DbSet<Payment> Payments { get; set; }
public DbSet<Buyer> Buyers { get; set; }
public DbSet<CardType> Cards { get; set; }
public DbSet<OrderStatus> OrderStatus { get; set; }
public DbSet<Address> Addresses { get; set; }
public OrderingContext(DbContextOptions options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Buyer>(ConfigureBuyer);
modelBuilder.Entity<Payment>(ConfigurePayment);
modelBuilder.Entity<Order>(ConfigureOrder);
modelBuilder.Entity<OrderItem>(ConfigureOrderItems);
modelBuilder.Entity<OrderStatus>()
.ToTable("orderstatus", DEFAULT_SCHEMA);
modelBuilder.Entity<CardType>()
.ToTable("cardtypes", DEFAULT_SCHEMA);
modelBuilder.Entity<Address>()
.ToTable("address", DEFAULT_SCHEMA);
}
void ConfigureBuyer(EntityTypeBuilder<Buyer> buyerConfiguration)
{
buyerConfiguration.ToTable("buyers", DEFAULT_SCHEMA);
buyerConfiguration.HasKey(b => b.Id);
buyerConfiguration.Property(b => b.Id)
.ForSqlServerUseSequenceHiLo("buyerseq", DEFAULT_SCHEMA);
buyerConfiguration.Property(b => b.FullName)
.HasMaxLength(200)
.IsRequired();
}
void ConfigurePayment(EntityTypeBuilder<Payment> 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<Order> 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);
orderConfiguration.HasOne(o => o.BillingAddress)
.WithMany()
.HasForeignKey(o => o.BillingAddressId)
.OnDelete(EntityFrameworkCore.Metadata.DeleteBehavior.SetNull);
orderConfiguration.HasOne(o => o.Buyer)
.WithMany()
.HasForeignKey(o => o.BuyerId);
orderConfiguration.HasOne(o => o.Status)
.WithMany()
.HasForeignKey(o => o.StatusId);
}
void ConfigureOrderItems(EntityTypeBuilder<OrderItem> 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();
}
}
}

src/Services/Ordering/Ordering.SqlData/Properties/AssemblyInfo.cs → src/Services/Ordering/Ordering.Infrastructure/Properties/AssemblyInfo.cs View File

@ -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.Infrastructure")]
[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("95f1f07c-4d92-4742-bd07-e5b805aab651")]

+ 16
- 0
src/Services/Ordering/Ordering.Infrastructure/project.json View File

@ -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"
}
}
}

+ 0
- 50
src/Services/Ordering/Ordering.SqlData/UnitOfWork/DBContextUtil.cs View File

@ -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<OrderingDbContext> 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<OrderingDbContext>();
builder.UseInMemoryDatabase()
.UseInternalServiceProvider(serviceProvider);
return builder.Options;
}
public static DbContextOptions<OrderingDbContext> CreateNewContextOptionsForSqlDb()
{
// Create a new options instance telling the context to use a Sql database
var builder = new DbContextOptionsBuilder<OrderingDbContext>();
//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;
}
}
}

+ 0
- 82
src/Services/Ordering/Ordering.SqlData/UnitOfWork/OrderingDbContext.cs View File

@ -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<OrderingDbContext> options)
: base(options)
{ }
public DbSet<Order> 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<int>("OrderSequences", schema: "shared")
.StartsAt(1001)
.IncrementsBy(1);
modelBuilder.Entity<Order>()
.Property(o => o.SequenceNumber)
.HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences");
}
public async Task<int> CommitAsync()
{
int changes = 0;
try
{
//(CDLTLL) TBD
//RemoveOrphanedChilds();
changes = await base.SaveChangesAsync();
}
catch (Exception ex)
{
//(CDLTLL) TBD
//RejectChanges();
throw ex;
}
return changes;
}
}
}

+ 0
- 19
src/Services/Ordering/Ordering.SqlData/project.json View File

@ -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" ]
}
}
}

+ 0
- 86
test/Services/Ordering.Test/DataIntegrationTests.cs View File

@ -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<Order>().ShippingAddress.City;
Assert.Equal("Redmond", cityName);
}
}
}
}

+ 1
- 7
test/Services/Ordering.Test/project.json View File

@ -4,13 +4,7 @@
"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": {


Loading…
Cancel
Save