diff --git a/eShopOnContainers.sln b/eShopOnContainers.sln index 4d8444598..0b78e08a1 100644 --- a/eShopOnContainers.sln +++ b/eShopOnContainers.sln @@ -45,6 +45,12 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Catalog.SqlData", "src\Serv 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 Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -91,6 +97,10 @@ Global {5DA6EF13-C7E0-4EC4-8599-A61C6AC2628D}.Debug|Any CPU.Build.0 = 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 + {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A0AFC432-3846-4B4E-BD8E-3C8C896F4967}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -112,5 +122,7 @@ Global {D78C4572-F8D8-4B49-ACD0-F0567CB15F0D} = {BF3EF4F3-E4F5-41DA-9D2D-57223687D1A8} {D9FDCDDA-7823-4043-8C40-634E5FD78046} = {326A7FB3-5295-468C-A4FE-67DCB823E1E5} {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} EndGlobalSection EndGlobal diff --git a/global.json b/global.json index e793049cd..c7e3a898f 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,9 @@ -{ - "projects": [ "src", "test" ], +{ + "projects": [ + "src", + "test" + ], + "sdk": { "version": "1.0.0-preview2-003121" } 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..a42dad001 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Controllers/OrdersController.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +using Microsoft.eShopOnContainers.Services.Ordering.API.UnitOfWork; +using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; + + +namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers +{ + [Route("api/[controller]")] + public class OrdersController : Controller + { + private OrderingContext _context; + + public OrdersController(OrderingContext context) + { + //Injected DbContext from the IoC container + _context = context; + } + + // GET api/orders + [HttpGet] + public IEnumerable Get() + { + //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); + _context.Orders.Add(order1); + _context.SaveChanges(); + + return _context.Orders.ToList(); + } + + // GET api/orders/xxxGUIDxxxx + [HttpGet("{id}")] + public string Get(Guid id) + { + return "value TBD"; + } + + // POST api/orders + [HttpPost] + public void Post([FromBody]Order order) + { + _context.Orders.Add(order); + _context.SaveChanges(); + } + + // PUT api/orders/xxxGUIDxxxx + [HttpPut("{id}")] + public void Put(int id, [FromBody]Order value) + { + + } + + // DELETE api/orders/xxxGUIDxxxx + [HttpDelete("{id}")] + public void Delete(Guid id) + { + + } + + } + +} + + diff --git a/src/Services/Ordering/Ordering.API/DTO/OrderItemDTO.cs b/src/Services/Ordering/Ordering.API/DTO/OrderItemDTO.cs index 1b25b28d9..82bdb25b1 100644 --- a/src/Services/Ordering/Ordering.API/DTO/OrderItemDTO.cs +++ b/src/Services/Ordering/Ordering.API/DTO/OrderItemDTO.cs @@ -2,7 +2,7 @@ using System.Runtime.Serialization; -namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order +namespace Microsoft.eShopOnContainers.Services.Ordering.API.DTO { [DataContract] public sealed class OrderItemDTO @@ -20,7 +20,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.O public override string ToString() { - return String.Format("ID: {0}, Quantity: {1}, Fulfillment Remaing: {2}", this.ItemId, this.Quantity, this.FulfillmentRemaining); + return String.Format("ID: {0}, Quantity: {1}, Fulfillment Remaing: {2}", this.Id, this.Quantity, this.FulfillmentRemaining); } } } diff --git a/src/Services/Ordering/Ordering.API/Migrations/20160909202620_MyFirstMigration.Designer.cs b/src/Services/Ordering/Ordering.API/Migrations/20160909202620_MyFirstMigration.Designer.cs new file mode 100644 index 000000000..02244954a --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Migrations/20160909202620_MyFirstMigration.Designer.cs @@ -0,0 +1,37 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.eShopOnContainers.Services.Ordering.API.UnitOfWork; + +namespace Ordering.API.Migrations +{ + [DbContext(typeof(OrderingContext))] + [Migration("20160909202620_MyFirstMigration")] + partial class MyFirstMigration + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("BuyerId"); + + b.Property("OrderDate"); + + b.Property("Status"); + + b.HasKey("Id"); + + b.ToTable("Orders"); + }); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20160909202620_MyFirstMigration.cs b/src/Services/Ordering/Ordering.API/Migrations/20160909202620_MyFirstMigration.cs new file mode 100644 index 000000000..62b9ff652 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Migrations/20160909202620_MyFirstMigration.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Ordering.API.Migrations +{ + public partial class MyFirstMigration : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(nullable: false), + BuyerId = table.Column(nullable: false), + OrderDate = table.Column(nullable: false), + Status = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Orders"); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20160909223213_Migration2.Designer.cs b/src/Services/Ordering/Ordering.API/Migrations/20160909223213_Migration2.Designer.cs new file mode 100644 index 000000000..5287cfba2 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Migrations/20160909223213_Migration2.Designer.cs @@ -0,0 +1,84 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.eShopOnContainers.Services.Ordering.API.UnitOfWork; + +namespace Ordering.API.Migrations +{ + [DbContext(typeof(OrderingContext))] + [Migration("20160909223213_Migration2")] + partial class Migration2 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") + .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("ShippingAddressId"); + + b.Property("Status"); + + b.HasKey("Id"); + + b.HasIndex("BillingAddressId"); + + b.HasIndex("ShippingAddressId"); + + b.ToTable("Orders"); + }); + + 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"); + }); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20160909223213_Migration2.cs b/src/Services/Ordering/Ordering.API/Migrations/20160909223213_Migration2.cs new file mode 100644 index 000000000..42f17a5d6 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Migrations/20160909223213_Migration2.cs @@ -0,0 +1,98 @@ +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.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.AddColumn( + name: "BillingAddressId", + table: "Orders", + nullable: true); + + migrationBuilder.AddColumn( + name: "ShippingAddressId", + table: "Orders", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Orders_BillingAddressId", + table: "Orders", + column: "BillingAddressId"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ShippingAddressId", + table: "Orders", + column: "ShippingAddressId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Address_BillingAddressId", + table: "Orders", + column: "BillingAddressId", + principalTable: "Address", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Address_ShippingAddressId", + table: "Orders", + column: "ShippingAddressId", + principalTable: "Address", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Address_BillingAddressId", + table: "Orders"); + + migrationBuilder.DropForeignKey( + name: "FK_Orders_Address_ShippingAddressId", + table: "Orders"); + + migrationBuilder.DropIndex( + name: "IX_Orders_BillingAddressId", + table: "Orders"); + + migrationBuilder.DropIndex( + name: "IX_Orders_ShippingAddressId", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "BillingAddressId", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "ShippingAddressId", + table: "Orders"); + + migrationBuilder.DropTable( + name: "Address"); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20160909233852_Migration3.Designer.cs b/src/Services/Ordering/Ordering.API/Migrations/20160909233852_Migration3.Designer.cs new file mode 100644 index 000000000..fc54e2c3c --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Migrations/20160909233852_Migration3.Designer.cs @@ -0,0 +1,84 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.eShopOnContainers.Services.Ordering.API.UnitOfWork; + +namespace Ordering.API.Migrations +{ + [DbContext(typeof(OrderingContext))] + [Migration("20160909233852_Migration3")] + partial class Migration3 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") + .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("ShippingAddressId"); + + b.Property("Status"); + + b.HasKey("Id"); + + b.HasIndex("BillingAddressId"); + + b.HasIndex("ShippingAddressId"); + + b.ToTable("Orders"); + }); + + 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"); + }); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Migrations/20160909233852_Migration3.cs b/src/Services/Ordering/Ordering.API/Migrations/20160909233852_Migration3.cs new file mode 100644 index 000000000..3b3ae2b73 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Migrations/20160909233852_Migration3.cs @@ -0,0 +1,19 @@ +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/OrderingContextModelSnapshot.cs b/src/Services/Ordering/Ordering.API/Migrations/OrderingContextModelSnapshot.cs new file mode 100644 index 000000000..01ea680c2 --- /dev/null +++ b/src/Services/Ordering/Ordering.API/Migrations/OrderingContextModelSnapshot.cs @@ -0,0 +1,83 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.eShopOnContainers.Services.Ordering.API.UnitOfWork; + +namespace Ordering.API.Migrations +{ + [DbContext(typeof(OrderingContext))] + partial class OrderingContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { + modelBuilder + .HasAnnotation("ProductVersion", "1.0.0-rtm-21431") + .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("ShippingAddressId"); + + b.Property("Status"); + + b.HasKey("Id"); + + b.HasIndex("BillingAddressId"); + + b.HasIndex("ShippingAddressId"); + + b.ToTable("Orders"); + }); + + 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"); + }); + } + } +} diff --git a/src/Services/Ordering/Ordering.API/Properties/launchSettings.json b/src/Services/Ordering/Ordering.API/Properties/launchSettings.json index f0374efc5..7af64c719 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/values", + "launchUrl": "api/orders", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 2b6b56448..33a7c1027 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -8,6 +8,9 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.eShopOnContainers.Services.Ordering.API.UnitOfWork; +using Microsoft.EntityFrameworkCore; + namespace Microsoft.eShopOnContainers.Services.Ordering.API { public class Startup @@ -24,11 +27,16 @@ 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 container. + // This method gets called by the runtime. + // Use this method to add services to the IoC container. public void ConfigureServices(IServiceCollection services) { // Add framework services. services.AddMvc(); + + //Add EF Core Context (UnitOfWork) + var connection = @"Server=(localdb)\mssqllocaldb;Database=Microsoft.eShopOnContainers.Services.OrderingDb;Trusted_Connection=True;"; + services.AddDbContext(options => options.UseSqlServer(connection)); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/src/Services/Ordering/Ordering.API/UnitOfWork/OrderingContext.cs b/src/Services/Ordering/Ordering.API/UnitOfWork/OrderingContext.cs new file mode 100644 index 000000000..83d2bd3cf --- /dev/null +++ b/src/Services/Ordering/Ordering.API/UnitOfWork/OrderingContext.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; + +namespace Microsoft.eShopOnContainers.Services.Ordering.API.UnitOfWork +{ + public class OrderingContext : DbContext + { + public OrderingContext(DbContextOptions options) + : base(options) + { } + + public DbSet Orders { get; set; } + + } +} diff --git a/src/Services/Ordering/Ordering.API/project.json b/src/Services/Ordering/Ordering.API/project.json index af6281beb..c50d2bd42 100644 --- a/src/Services/Ordering/Ordering.API/project.json +++ b/src/Services/Ordering/Ordering.API/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Microsoft.NETCore.App": { "version": "1.0.0", @@ -13,10 +13,16 @@ "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.Extensions.Options.ConfigurationExtensions": "1.0.0", + "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0", + "Microsoft.EntityFrameworkCore": "1.0.0", + "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0", + "Ordering.Domain": "1.0.0-*", + "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" }, "tools": { + "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final", "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" }, diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Buyer/Buyer.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Buyer/Buyer.cs index eaa041a12..9157369a5 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Buyer/Buyer.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Buyer/Buyer.cs @@ -7,7 +7,7 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel { public Buyer(Guid buyerId, string name, string lastName, string email, Address address, string phoneNumber) { - this.BuyerId = buyerId; + this.Id = buyerId; this.Name = name; this.LastName = lastName; this.Email = email; @@ -15,13 +15,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel this.PhoneNumber = phoneNumber; } - protected Buyer() { } // infrastructure - - public virtual Guid BuyerId - { - get; - private set; - } public virtual string Name { diff --git a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Address.cs b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Address.cs index 0e27b23ec..9114b2f93 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Address.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Address.cs @@ -5,60 +5,66 @@ using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel { - public class Address : ValueObject
//A VO doesn't have IDENTITY, like in this case, the Address + public class Address : ValueObject
{ - public virtual String Street + public Address(string street, + string city, + string state, + string stateCode, + string country, + string countryCode, + string zipCode, + double latitude = 0, + double longitude = 0 + ) { - get; - private set; - } + if (street == null) + throw new ArgumentNullException("street"); - public virtual String City - { - get; - private set; - } + if (city == null) + throw new ArgumentNullException("city"); - public virtual String State - { - get; - private set; - } + if (state == null) + throw new ArgumentNullException("state"); - public virtual String StateCode - { - get; - private set; - } + if (stateCode == null) + throw new ArgumentNullException("stateCode"); - public virtual String Country - { - get; - private set; - } + if (country == null) + throw new ArgumentNullException("country"); - public virtual String CountryCode - { - get; - private set; - } + if (countryCode == null) + throw new ArgumentNullException("countryCode"); - public virtual String ZipCode - { - get; - private set; - } + if (zipCode == null) + throw new ArgumentNullException("zipCode"); - public virtual double Latitude - { - get; - private set; - } + //Generate the ID guid - Remove this when EF Core supports ValueObjects + // https://github.com/aspnet/EntityFramework/issues/246 + this.Id = Guid.NewGuid(); - public virtual double Longitude - { - get; - private set; + 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 index 92b3763b8..e71e922ad 100644 --- a/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Order.cs +++ b/src/Services/Ordering/Ordering.Domain/AggregatesModel/Order/Order.cs @@ -22,56 +22,37 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel this.OrderDate = orderDate; } - protected Order() { } // Infrastructure. EF might need a plain constructor. Do not use. + //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(); + //List _orderItems; + //public virtual List orderItems + //{ + // get + // { + // if (_orderItems == null) + // _orderItems = new List(); - return _orderItems; - } - - private set - { - _orderItems = value; - } - } + // return _orderItems; + // } - public virtual Guid BuyerId - { - get; - private set; - } + // private set + // { + // _orderItems = value; + // } + //} - public virtual Address ShippingAddress - { - get; - private set; - } + public virtual Guid BuyerId { get; private set; } - public virtual Address BillingAddress - { - 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 DateTime OrderDate { get; private set; } - public virtual OrderStatus Status - { - get; - set; - } + public virtual OrderStatus Status { get; private set; } } } diff --git a/src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs b/src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs index 9369e6a7d..43b377183 100644 --- a/src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs +++ b/src/Services/Ordering/Ordering.Domain/SeedWork/ValueObject.cs @@ -14,6 +14,11 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork 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 diff --git a/src/Web/Microsoft.eShopOnContainers.WebMVC/project.json b/src/Web/Microsoft.eShopOnContainers.WebMVC/project.json index 8f00e7d3a..726c2fef3 100644 --- a/src/Web/Microsoft.eShopOnContainers.WebMVC/project.json +++ b/src/Web/Microsoft.eShopOnContainers.WebMVC/project.json @@ -1,4 +1,4 @@ -{ +{ "userSecretsId": "aspnet-Microsoft.eShopOnContainers.WebMVC-946ae052-8305-4a99-965b-ec8636ddbae3", "dependencies": { @@ -23,10 +23,6 @@ "version": "1.0.0", "type": "build" }, - "Microsoft.EntityFrameworkCore.Tools": { - "version": "1.0.0-preview2-final", - "type": "build" - }, "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", "Microsoft.Extensions.Configuration.Json": "1.0.0", "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0", diff --git a/test/Services/Ordering.Test/Ordering.Test.xproj b/test/Services/Ordering.Test/Ordering.Test.xproj new file mode 100644 index 000000000..a9a2e84b9 --- /dev/null +++ b/test/Services/Ordering.Test/Ordering.Test.xproj @@ -0,0 +1,19 @@ + + + + 14.0.25420 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + a0afc432-3846-4b4e-bd8e-3c8c896f4967 + Ordering.Test + .\obj + .\bin\ + + + + 2.0 + + + \ No newline at end of file diff --git a/test/Services/Ordering.Test/Tests.cs b/test/Services/Ordering.Test/Tests.cs new file mode 100644 index 000000000..1bd5ced4f --- /dev/null +++ b/test/Services/Ordering.Test/Tests.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace Tests +{ + public class Tests + { + [Fact] + public void Test1() + { + Assert.True(true); + } + } +} diff --git a/test/Services/Ordering.Test/project.json b/test/Services/Ordering.Test/project.json new file mode 100644 index 000000000..2a9b55577 --- /dev/null +++ b/test/Services/Ordering.Test/project.json @@ -0,0 +1,26 @@ +{ + "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" + }, + "testRunner": "xunit", + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": [ + "dotnet5.4", + "portable-net451+win8" + ] + } + } +} diff --git a/test/Services/Ordering.TestsOLD/Ordering.Tests.xproj b/test/Services/Ordering.TestsOLD/Ordering.Tests.xproj new file mode 100644 index 000000000..80f992088 --- /dev/null +++ b/test/Services/Ordering.TestsOLD/Ordering.Tests.xproj @@ -0,0 +1,21 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + 9b26282e-d550-4289-9a18-3334023c4f69 + Ordering.Tests + .\obj + .\bin\ + v4.6 + + + + 2.0 + + + diff --git a/test/Services/Ordering.TestsOLD/Properties/AssemblyInfo.cs b/test/Services/Ordering.TestsOLD/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..c6794bc99 --- /dev/null +++ b/test/Services/Ordering.TestsOLD/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.Tests")] +[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("9b26282e-d550-4289-9a18-3334023c4f69")] diff --git a/test/Services/Ordering.TestsOLD/project.json b/test/Services/Ordering.TestsOLD/project.json new file mode 100644 index 000000000..9a71f253f --- /dev/null +++ b/test/Services/Ordering.TestsOLD/project.json @@ -0,0 +1,13 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "NETStandard.Library": "1.6.0" + }, + + "frameworks": { + "netstandard1.6": { + "imports": "dnxcore50" + } + } +}