@ -1,5 +1,9 @@ | |||
{ | |||
"projects": [ "src", "test" ], | |||
{ | |||
"projects": [ | |||
"src", | |||
"test" | |||
], | |||
"sdk": { | |||
"version": "1.0.0-preview2-003121" | |||
} | |||
@ -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<Order> 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) | |||
{ | |||
} | |||
} | |||
} | |||
@ -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<Guid>("Id") | |||
.ValueGeneratedOnAdd(); | |||
b.Property<Guid>("BuyerId"); | |||
b.Property<DateTime>("OrderDate"); | |||
b.Property<int>("Status"); | |||
b.HasKey("Id"); | |||
b.ToTable("Orders"); | |||
}); | |||
} | |||
} | |||
} |
@ -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<Guid>(nullable: false), | |||
BuyerId = table.Column<Guid>(nullable: false), | |||
OrderDate = table.Column<DateTime>(nullable: false), | |||
Status = table.Column<int>(nullable: false) | |||
}, | |||
constraints: table => | |||
{ | |||
table.PrimaryKey("PK_Orders", x => x.Id); | |||
}); | |||
} | |||
protected override void Down(MigrationBuilder migrationBuilder) | |||
{ | |||
migrationBuilder.DropTable( | |||
name: "Orders"); | |||
} | |||
} | |||
} |
@ -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<Guid>("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"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => | |||
{ | |||
b.Property<Guid>("Id") | |||
.ValueGeneratedOnAdd(); | |||
b.Property<Guid?>("BillingAddressId"); | |||
b.Property<Guid>("BuyerId"); | |||
b.Property<DateTime>("OrderDate"); | |||
b.Property<Guid?>("ShippingAddressId"); | |||
b.Property<int>("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"); | |||
}); | |||
} | |||
} | |||
} |
@ -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<Guid>(nullable: false), | |||
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.AddColumn<Guid>( | |||
name: "BillingAddressId", | |||
table: "Orders", | |||
nullable: true); | |||
migrationBuilder.AddColumn<Guid>( | |||
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"); | |||
} | |||
} | |||
} |
@ -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<Guid>("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"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => | |||
{ | |||
b.Property<Guid>("Id") | |||
.ValueGeneratedOnAdd(); | |||
b.Property<Guid?>("BillingAddressId"); | |||
b.Property<Guid>("BuyerId"); | |||
b.Property<DateTime>("OrderDate"); | |||
b.Property<Guid?>("ShippingAddressId"); | |||
b.Property<int>("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"); | |||
}); | |||
} | |||
} | |||
} |
@ -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) | |||
{ | |||
} | |||
} | |||
} |
@ -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<Guid>("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"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => | |||
{ | |||
b.Property<Guid>("Id") | |||
.ValueGeneratedOnAdd(); | |||
b.Property<Guid?>("BillingAddressId"); | |||
b.Property<Guid>("BuyerId"); | |||
b.Property<DateTime>("OrderDate"); | |||
b.Property<Guid?>("ShippingAddressId"); | |||
b.Property<int>("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"); | |||
}); | |||
} | |||
} | |||
} |
@ -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<OrderingContext> options) | |||
: base(options) | |||
{ } | |||
public DbSet<Order> Orders { get; set; } | |||
} | |||
} |
@ -0,0 +1,19 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<PropertyGroup> | |||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion> | |||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | |||
</PropertyGroup> | |||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>a0afc432-3846-4b4e-bd8e-3c8c896f4967</ProjectGuid> | |||
<RootNamespace>Ordering.Test</RootNamespace> | |||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | |||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | |||
</PropertyGroup> | |||
<PropertyGroup> | |||
<SchemaVersion>2.0</SchemaVersion> | |||
</PropertyGroup> | |||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> | |||
</Project> |
@ -0,0 +1,14 @@ | |||
using System; | |||
using Xunit; | |||
namespace Tests | |||
{ | |||
public class Tests | |||
{ | |||
[Fact] | |||
public void Test1() | |||
{ | |||
Assert.True(true); | |||
} | |||
} | |||
} |
@ -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" | |||
] | |||
} | |||
} | |||
} |
@ -0,0 +1,21 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
<PropertyGroup> | |||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | |||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | |||
</PropertyGroup> | |||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | |||
<PropertyGroup Label="Globals"> | |||
<ProjectGuid>9b26282e-d550-4289-9a18-3334023c4f69</ProjectGuid> | |||
<RootNamespace>Ordering.Tests</RootNamespace> | |||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | |||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | |||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion> | |||
</PropertyGroup> | |||
<PropertyGroup> | |||
<SchemaVersion>2.0</SchemaVersion> | |||
</PropertyGroup> | |||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> | |||
</Project> |
@ -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")] |
@ -0,0 +1,13 @@ | |||
{ | |||
"version": "1.0.0-*", | |||
"dependencies": { | |||
"NETStandard.Library": "1.6.0" | |||
}, | |||
"frameworks": { | |||
"netstandard1.6": { | |||
"imports": "dnxcore50" | |||
} | |||
} | |||
} |