- SQL DB updated with EF Migrations - build-images.ps1 updatedpull/49/merge
@ -0,0 +1,123 @@ | |||
using System; | |||
using Microsoft.EntityFrameworkCore; | |||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||
using Microsoft.EntityFrameworkCore.Metadata; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||
namespace Ordering.API.Migrations | |||
{ | |||
[DbContext(typeof(OrderingDbContext))] | |||
[Migration("20161011040943_Migration2")] | |||
partial class Migration2 | |||
{ | |||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||
{ | |||
modelBuilder | |||
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431") | |||
.HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => | |||
{ | |||
b.Property<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<int>("SequenceNumber") | |||
.ValueGeneratedOnAdd() | |||
.HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); | |||
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.OrderItem", b => | |||
{ | |||
b.Property<Guid>("Id") | |||
.ValueGeneratedOnAdd(); | |||
b.Property<decimal>("Discount"); | |||
b.Property<int>("FulfillmentRemaining"); | |||
b.Property<Guid>("OrderId"); | |||
b.Property<Guid>("ProductId"); | |||
b.Property<string>("ProductName"); | |||
b.Property<int>("Quantity"); | |||
b.Property<decimal>("UnitPrice"); | |||
b.HasKey("Id"); | |||
b.HasIndex("OrderId"); | |||
b.ToTable("OrderItem"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => | |||
{ | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "BillingAddress") | |||
.WithMany() | |||
.HasForeignKey("BillingAddressId"); | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "ShippingAddress") | |||
.WithMany() | |||
.HasForeignKey("ShippingAddressId"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => | |||
{ | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order") | |||
.WithMany("OrderItems") | |||
.HasForeignKey("OrderId") | |||
.OnDelete(DeleteBehavior.Cascade); | |||
}); | |||
} | |||
} | |||
} |
@ -0,0 +1,24 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
namespace Ordering.API.Migrations | |||
{ | |||
public partial class Migration2 : Migration | |||
{ | |||
protected override void Up(MigrationBuilder migrationBuilder) | |||
{ | |||
migrationBuilder.AddColumn<string>( | |||
name: "ProductName", | |||
table: "OrderItem", | |||
nullable: true); | |||
} | |||
protected override void Down(MigrationBuilder migrationBuilder) | |||
{ | |||
migrationBuilder.DropColumn( | |||
name: "ProductName", | |||
table: "OrderItem"); | |||
} | |||
} | |||
} |
@ -0,0 +1,123 @@ | |||
using System; | |||
using Microsoft.EntityFrameworkCore; | |||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||
using Microsoft.EntityFrameworkCore.Metadata; | |||
using Microsoft.EntityFrameworkCore.Migrations; | |||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||
namespace Ordering.API.Migrations | |||
{ | |||
[DbContext(typeof(OrderingDbContext))] | |||
[Migration("20161011041130_Migration3")] | |||
partial class Migration3 | |||
{ | |||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||
{ | |||
modelBuilder | |||
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431") | |||
.HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") | |||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => | |||
{ | |||
b.Property<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<int>("SequenceNumber") | |||
.ValueGeneratedOnAdd() | |||
.HasDefaultValueSql("NEXT VALUE FOR shared.OrderSequences"); | |||
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.OrderItem", b => | |||
{ | |||
b.Property<Guid>("Id") | |||
.ValueGeneratedOnAdd(); | |||
b.Property<decimal>("Discount"); | |||
b.Property<int>("FulfillmentRemaining"); | |||
b.Property<Guid>("OrderId"); | |||
b.Property<Guid>("ProductId"); | |||
b.Property<string>("ProductName"); | |||
b.Property<int>("Quantity"); | |||
b.Property<decimal>("UnitPrice"); | |||
b.HasKey("Id"); | |||
b.HasIndex("OrderId"); | |||
b.ToTable("OrderItem"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order", b => | |||
{ | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "BillingAddress") | |||
.WithMany() | |||
.HasForeignKey("BillingAddressId"); | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", "ShippingAddress") | |||
.WithMany() | |||
.HasForeignKey("ShippingAddressId"); | |||
}); | |||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.OrderItem", b => | |||
{ | |||
b.HasOne("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Order") | |||
.WithMany("OrderItems") | |||
.HasForeignKey("OrderId") | |||
.OnDelete(DeleteBehavior.Cascade); | |||
}); | |||
} | |||
} | |||
} |
@ -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,3 @@ | |||
{ | |||
"ConnectionString": "Server=127.0.0.1;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;" | |||
} |
@ -1,19 +0,0 @@ | |||
{ | |||
"iisSettings": { | |||
"windowsAuthentication": false, | |||
"anonymousAuthentication": true, | |||
"iisExpress": { | |||
"applicationUrl": "http://localhost:2113/", | |||
"sslPort": 0 | |||
} | |||
}, | |||
"profiles": { | |||
"IIS Express": { | |||
"commandName": "IISExpress", | |||
"launchBrowser": true, | |||
"environmentVariables": { | |||
"ASPNETCORE_ENVIRONMENT": "Development" | |||
} | |||
} | |||
} | |||
} |
@ -0,0 +1,21 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Threading.Tasks; | |||
namespace Microsoft.eShopOnContainers.WebMVC.Models | |||
{ | |||
public class Address | |||
{ | |||
public Guid ID { get; set; } | |||
public string Street { get; set; } | |||
public string City { get; set; } | |||
public string State { get; set; } | |||
public string StateCode { get; set; } | |||
public string Country { get; set; } | |||
public string CountryCode { get; set; } | |||
public string ZipCode { get; set; } | |||
public double Latitude { get; set; } | |||
public double Longitude { get; set; } | |||
} | |||
} |
@ -0,0 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Threading.Tasks; | |||
namespace Microsoft.eShopOnContainers.WebMVC.Models | |||
{ | |||
public class Order | |||
{ | |||
Guid Id; | |||
public List<OrderItem> OrderItems { get; set; } | |||
public string OrderNumber | |||
{ | |||
get | |||
{ | |||
return string.Format("{0}/{1}-{2}", OrderDate.Year, OrderDate.Month, SequenceNumber); | |||
} | |||
} | |||
public int SequenceNumber { get; set; } | |||
public virtual Guid BuyerId { get; set; } | |||
public virtual Address ShippingAddress { get; set; } | |||
public virtual Address BillingAddress { get; set; } | |||
public virtual DateTime OrderDate { get; set; } | |||
//(CDLTLL) public virtual OrderStatus Status { get; set; } | |||
} | |||
} |
@ -0,0 +1,23 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Threading.Tasks; | |||
namespace Microsoft.eShopOnContainers.WebMVC.Models | |||
{ | |||
public class OrderItem | |||
{ | |||
Guid Id; | |||
public Guid ProductId { get; set; } | |||
public Guid OrderId { get; set; } | |||
public string ProductName { get; set; } | |||
public decimal UnitPrice { get; set; } | |||
public int Quantity { get; set; } | |||
public decimal Discount { get; set; } | |||
public override string ToString() | |||
{ | |||
return String.Format("Product Id: {0}, Quantity: {1}", this.Id, this.Quantity); | |||
} | |||
} | |||
} |
@ -0,0 +1,50 @@ | |||
@{ | |||
ViewData["Title"] = "Orders"; | |||
@model IEnumerable<Order> | |||
} | |||
<h2>@ViewData["Title"].</h2> | |||
<h3>@ViewData["Message"]</h3> | |||
@foreach (var order in Model) | |||
{ | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title"> | |||
<strong>Order Number:</strong> @order.OrderNumber | |||
</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<strong>BuyerId: </strong> @order.BuyerId <br /> | |||
<strong>OrderDate: </strong> @order.OrderDate <br /> | |||
<strong>SequenceNumber: </strong> @order.SequenceNumber <br /> | |||
</div> | |||
<div class="panel-body"> | |||
<address> | |||
<strong>Street: </strong> @order.ShippingAddress.Street <br /> | |||
<strong>City: </strong> @order.ShippingAddress.City <br /> | |||
<strong>State: </strong> @order.ShippingAddress.State <br /> | |||
<strong>StateCode: </strong> @order.ShippingAddress.StateCode <br /> | |||
<strong>Country: </strong> @order.ShippingAddress.Country <br /> | |||
<strong>CountryCode: </strong> @order.ShippingAddress.CountryCode <br /> | |||
<strong>ZipCode: </strong> @order.ShippingAddress.ZipCode <br /> | |||
<strong>Latitude: </strong> @order.ShippingAddress.Latitude <br /> | |||
<strong>Longitude: </strong> @order.ShippingAddress.Longitude <br /> | |||
</address> | |||
</div> | |||
<div class="panel-body"> | |||
@foreach (var orderItem in order.OrderItems) | |||
{ | |||
<address> | |||
<strong>ProductId: </strong> @orderItem.ProductId <br /> | |||
<strong>ProductName: </strong> @orderItem.ProductName <br /> | |||
<strong>Price: </strong> @orderItem.UnitPrice <br /> | |||
<strong>Quantity: </strong> @orderItem.Quantity <br /> | |||
<strong>Discount: </strong> @orderItem.Discount <br /> | |||
</address> | |||
} | |||
</div> | |||
</div> | |||
} | |||