@ -1,41 +0,0 @@ | |||||
{ | |||||
"version": "0.2.0", | |||||
"configurations": [ | |||||
{ | |||||
"name": ".NET Core Launch (web)", | |||||
"type": "coreclr", | |||||
"request": "launch", | |||||
"preLaunchTask": "build", | |||||
"program": "${workspaceRoot}\\bin\\Debug\\netcoreapp1.0\\Ordering.API.dll", | |||||
"args": [], | |||||
"cwd": "${workspaceRoot}", | |||||
"stopAtEntry": false, | |||||
"launchBrowser": { | |||||
"enabled": true, | |||||
"args": "${auto-detect-url}", | |||||
"windows": { | |||||
"command": "cmd.exe", | |||||
"args": "/C start ${auto-detect-url}" | |||||
}, | |||||
"osx": { | |||||
"command": "open" | |||||
}, | |||||
"linux": { | |||||
"command": "xdg-open" | |||||
} | |||||
}, | |||||
"env": { | |||||
"ASPNETCORE_ENVIRONMENT": "Development" | |||||
}, | |||||
"sourceFileMap": { | |||||
"/Views": "${workspaceRoot}/Views" | |||||
} | |||||
}, | |||||
{ | |||||
"name": ".NET Core Attach", | |||||
"type": "coreclr", | |||||
"request": "attach", | |||||
"processId": "${command.pickProcess}" | |||||
} | |||||
] | |||||
} |
@ -1,16 +0,0 @@ | |||||
{ | |||||
"version": "0.1.0", | |||||
"command": "dotnet", | |||||
"isShellCommand": true, | |||||
"args": [], | |||||
"tasks": [ | |||||
{ | |||||
"taskName": "build", | |||||
"args": [ | |||||
"${workspaceRoot}\\project.json" | |||||
], | |||||
"isBuildCommand": true, | |||||
"problemMatcher": "$msCompile" | |||||
} | |||||
] | |||||
} |
@ -1,23 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.AspNetCore.Mvc; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers | |||||
{ | |||||
[Route("api/[controller]")] | |||||
public class EnvironmentInfoController : Controller | |||||
{ | |||||
// GET api/environmentInfo/machinename | |||||
[HttpGet("machinename")] | |||||
public dynamic GetMachineName() | |||||
{ | |||||
return new | |||||
{ | |||||
InstanceName = Environment.MachineName | |||||
}; | |||||
} | |||||
} | |||||
} |
@ -1,129 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; | |||||
using Microsoft.EntityFrameworkCore; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers | |||||
{ | |||||
[Route("api/[controller]")] | |||||
public class OrderingController : Controller | |||||
{ | |||||
private IOrderRepository _orderRepository; | |||||
private IOrderdingQueries _queries; | |||||
//private OrderingDbContext _context; | |||||
public OrderingController(IOrderRepository orderRepository, | |||||
IOrderdingQueries orderingQueries //, | |||||
//OrderingDbContext context | |||||
) | |||||
{ | |||||
//Injected objects from the IoC container | |||||
_orderRepository = orderRepository; | |||||
_queries = orderingQueries; | |||||
//_context = context; | |||||
} | |||||
// GET api/ordering/orders | |||||
[HttpGet("orders")] | |||||
public async Task<IActionResult> GetAllOrders() | |||||
{ | |||||
dynamic response = await _queries.GetAllOrdersIncludingValueObjectsAndChildEntities(); | |||||
return Ok(response); | |||||
} | |||||
// GET api/ordering/orders/xxxGUIDxxxx | |||||
[HttpGet("orders/{orderId:Guid}")] | |||||
public async Task<IActionResult> GetOrderById(Guid orderId) | |||||
{ | |||||
dynamic response = await _queries.GetOrderById(orderId); | |||||
return Ok(response); | |||||
} | |||||
//(CDLTLL) - Using parameters | |||||
//Alternate method if using several parameters instead of part of the URL | |||||
// GET api/ordering/orders/?orderId=xxxGUIDxxx&otherParam=value | |||||
//[HttpGet("orders")] | |||||
//public Order GetOrderByGuid([FromUri] Guid orderId, [FromUri] string otherParam) | |||||
// POST api/ordering/orders/create | |||||
[HttpPut("orders/create")] | |||||
public async Task<IActionResult> Post([FromBody]Order order) | |||||
{ | |||||
_orderRepository.Add(order); | |||||
int numChanges = await _orderRepository.UnitOfWork.CommitAsync(); | |||||
return Ok(numChanges); | |||||
} | |||||
// PUT api/ordering/orders/xxxOrderGUIDxxxx/update | |||||
[HttpPut("orders/{orderId:Guid}/update")] | |||||
public async Task<IActionResult> UpdateOrder(Guid orderID, [FromBody] Order orderToUpdate) | |||||
{ | |||||
_orderRepository.Update(orderToUpdate); | |||||
int numChanges = await _orderRepository.UnitOfWork.CommitAsync(); | |||||
return Ok(numChanges); | |||||
} | |||||
// DELETE api/ordering/orders/xxxOrderGUIDxxxx | |||||
[HttpDelete("orders/{orderId:Guid}/remove")] | |||||
public async Task<IActionResult> Remove(Guid id) | |||||
{ | |||||
await _orderRepository.Remove(id); | |||||
int numChanges = await _orderRepository.UnitOfWork.CommitAsync(); | |||||
return Ok(numChanges); | |||||
} | |||||
// GET api/ordering/orders/add_test_data_and_get_all | |||||
[HttpGet("orders/add_test_data_and_get_all")] | |||||
public async Task<IActionResult> AddTestDataAndGetAllOrders() | |||||
{ | |||||
//TEST ADDING ORDERS ********************************* | |||||
//Create generic Address ValueObject | |||||
Address sampleAddress = new Address("15703 NE 61st Ct.", | |||||
"Redmond", | |||||
"Washington", | |||||
"WA", | |||||
"United States", | |||||
"US", | |||||
"98052", | |||||
47.661492, | |||||
-122.131309 | |||||
); | |||||
//Create sample Orders | |||||
Order order1 = new Order(Guid.NewGuid(), sampleAddress, sampleAddress); | |||||
//Add a few OrderItems | |||||
order1.AddNewOrderItem(Guid.NewGuid(), 2, 25, 30); | |||||
order1.AddNewOrderItem(Guid.NewGuid(), 1, 58, 0); | |||||
order1.AddNewOrderItem(Guid.NewGuid(), 1, 60, 0); | |||||
order1.AddNewOrderItem(Guid.NewGuid(), 3, 12, 0); | |||||
order1.AddNewOrderItem(Guid.NewGuid(), 5, 3, 0); | |||||
_orderRepository.Add(order1); | |||||
int numRecs = await _orderRepository.UnitOfWork.CommitAsync(); | |||||
//_context.Orders.Add(order1); | |||||
//_context.SaveChanges(); | |||||
//***************************************************** | |||||
dynamic response = await _queries.GetAllOrdersIncludingValueObjectsAndChildEntities(); | |||||
return Ok(response); | |||||
} | |||||
} | |||||
} | |||||
@ -0,0 +1,97 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Controllers | |||||
{ | |||||
using Application.Commands; | |||||
using Application.Queries; | |||||
using MediatR; | |||||
using Microsoft.AspNetCore.Mvc; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
[Route("api/v1/[controller]")] | |||||
public class OrdersController : Controller | |||||
{ | |||||
private readonly IMediator _mediator; | |||||
private readonly IOrderQueries _orderQueries; | |||||
public OrdersController(IMediator mediator,IOrderQueries orderQueries) | |||||
{ | |||||
if (mediator == null) | |||||
{ | |||||
throw new ArgumentNullException(nameof(mediator)); | |||||
} | |||||
if (orderQueries == null) | |||||
{ | |||||
throw new ArgumentNullException(nameof(orderQueries)); | |||||
} | |||||
_mediator = mediator; | |||||
_orderQueries = orderQueries; | |||||
} | |||||
[Route("new")] | |||||
[HttpPost] | |||||
public async Task<IActionResult> AddOrder() | |||||
{ | |||||
var newOrderRequest = new NewOrderRequest(); | |||||
var added = await _mediator.SendAsync(newOrderRequest); | |||||
if (added) | |||||
{ | |||||
return Ok(); | |||||
} | |||||
return BadRequest(); | |||||
} | |||||
[Route("cancel/{orderId:int}")] | |||||
[HttpPost] | |||||
public async Task<IActionResult> CancelOrder(int orderId) | |||||
{ | |||||
var cancelOrderRequest = new CancelOrderRequest(orderId); | |||||
var cancelled = await _mediator.SendAsync(cancelOrderRequest); | |||||
if (cancelled) | |||||
{ | |||||
return Ok(); | |||||
} | |||||
return BadRequest(); | |||||
} | |||||
[Route("{orderId:int}")] | |||||
[HttpGet] | |||||
public async Task<IActionResult> GetOrder(int orderId) | |||||
{ | |||||
var order = await _orderQueries.GetOrder(orderId); | |||||
if ( order != null) | |||||
{ | |||||
Ok(order); | |||||
} | |||||
return NotFound(); | |||||
} | |||||
[Route("pending")] | |||||
[HttpGet] | |||||
public async Task<IActionResult> GetPendingOrders(int orderId) | |||||
{ | |||||
var orders = await _orderQueries.GetPendingOrders(); | |||||
if (orders.Any()) | |||||
{ | |||||
Ok(orders); | |||||
} | |||||
return NoContent(); | |||||
} | |||||
} | |||||
} | |||||
@ -1,121 +0,0 @@ | |||||
using System; | |||||
using Microsoft.EntityFrameworkCore; | |||||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||||
using Microsoft.EntityFrameworkCore.Metadata; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
[DbContext(typeof(OrderingDbContext))] | |||||
[Migration("20160913204939_Migration1")] | |||||
partial class Migration1 | |||||
{ | |||||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||||
{ | |||||
modelBuilder | |||||
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431") | |||||
.HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") | |||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => | |||||
{ | |||||
b.Property<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<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); | |||||
}); | |||||
} | |||||
} | |||||
} |
@ -1,123 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
public partial class Migration1 : Migration | |||||
{ | |||||
protected override void Up(MigrationBuilder migrationBuilder) | |||||
{ | |||||
migrationBuilder.EnsureSchema( | |||||
name: "shared"); | |||||
migrationBuilder.CreateSequence<int>( | |||||
name: "OrderSequences", | |||||
schema: "shared", | |||||
startValue: 1001L); | |||||
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.CreateTable( | |||||
name: "Orders", | |||||
columns: table => new | |||||
{ | |||||
Id = table.Column<Guid>(nullable: false), | |||||
BillingAddressId = table.Column<Guid>(nullable: true), | |||||
BuyerId = table.Column<Guid>(nullable: false), | |||||
OrderDate = table.Column<DateTime>(nullable: false), | |||||
SequenceNumber = table.Column<int>(nullable: false, defaultValueSql: "NEXT VALUE FOR shared.OrderSequences"), | |||||
ShippingAddressId = table.Column<Guid>(nullable: true), | |||||
Status = 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, | |||||
principalTable: "Address", | |||||
principalColumn: "Id", | |||||
onDelete: ReferentialAction.Restrict); | |||||
table.ForeignKey( | |||||
name: "FK_Orders_Address_ShippingAddressId", | |||||
column: x => x.ShippingAddressId, | |||||
principalTable: "Address", | |||||
principalColumn: "Id", | |||||
onDelete: ReferentialAction.Restrict); | |||||
}); | |||||
migrationBuilder.CreateTable( | |||||
name: "OrderItem", | |||||
columns: table => new | |||||
{ | |||||
Id = table.Column<Guid>(nullable: false), | |||||
Discount = table.Column<decimal>(nullable: false), | |||||
FulfillmentRemaining = table.Column<int>(nullable: false), | |||||
OrderId = table.Column<Guid>(nullable: false), | |||||
ProductId = table.Column<Guid>(nullable: false), | |||||
Quantity = table.Column<int>(nullable: false), | |||||
UnitPrice = table.Column<decimal>(nullable: false) | |||||
}, | |||||
constraints: table => | |||||
{ | |||||
table.PrimaryKey("PK_OrderItem", x => x.Id); | |||||
table.ForeignKey( | |||||
name: "FK_OrderItem_Orders_OrderId", | |||||
column: x => x.OrderId, | |||||
principalTable: "Orders", | |||||
principalColumn: "Id", | |||||
onDelete: ReferentialAction.Cascade); | |||||
}); | |||||
migrationBuilder.CreateIndex( | |||||
name: "IX_Orders_BillingAddressId", | |||||
table: "Orders", | |||||
column: "BillingAddressId"); | |||||
migrationBuilder.CreateIndex( | |||||
name: "IX_Orders_ShippingAddressId", | |||||
table: "Orders", | |||||
column: "ShippingAddressId"); | |||||
migrationBuilder.CreateIndex( | |||||
name: "IX_OrderItem_OrderId", | |||||
table: "OrderItem", | |||||
column: "OrderId"); | |||||
} | |||||
protected override void Down(MigrationBuilder migrationBuilder) | |||||
{ | |||||
migrationBuilder.DropSequence( | |||||
name: "OrderSequences", | |||||
schema: "shared"); | |||||
migrationBuilder.DropTable( | |||||
name: "OrderItem"); | |||||
migrationBuilder.DropTable( | |||||
name: "Orders"); | |||||
migrationBuilder.DropTable( | |||||
name: "Address"); | |||||
} | |||||
} | |||||
} |
@ -1,121 +0,0 @@ | |||||
using System; | |||||
using Microsoft.EntityFrameworkCore; | |||||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||||
using Microsoft.EntityFrameworkCore.Metadata; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
[DbContext(typeof(OrderingDbContext))] | |||||
[Migration("20161005002014_Migration_Baseline")] | |||||
partial class Migration_Baseline | |||||
{ | |||||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||||
{ | |||||
modelBuilder | |||||
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431") | |||||
.HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") | |||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => | |||||
{ | |||||
b.Property<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<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); | |||||
}); | |||||
} | |||||
} | |||||
} |
@ -1,19 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
public partial class Migration_Baseline : Migration | |||||
{ | |||||
protected override void Up(MigrationBuilder migrationBuilder) | |||||
{ | |||||
} | |||||
protected override void Down(MigrationBuilder migrationBuilder) | |||||
{ | |||||
} | |||||
} | |||||
} |
@ -1,121 +0,0 @@ | |||||
using System; | |||||
using Microsoft.EntityFrameworkCore; | |||||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||||
using Microsoft.EntityFrameworkCore.Metadata; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
[DbContext(typeof(OrderingDbContext))] | |||||
[Migration("20161005003321_Migration_Cero")] | |||||
partial class Migration_Cero | |||||
{ | |||||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||||
{ | |||||
modelBuilder | |||||
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431") | |||||
.HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") | |||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => | |||||
{ | |||||
b.Property<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<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); | |||||
}); | |||||
} | |||||
} | |||||
} |
@ -1,19 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
public partial class Migration_Cero : Migration | |||||
{ | |||||
protected override void Up(MigrationBuilder migrationBuilder) | |||||
{ | |||||
} | |||||
protected override void Down(MigrationBuilder migrationBuilder) | |||||
{ | |||||
} | |||||
} | |||||
} |
@ -1,123 +0,0 @@ | |||||
using System; | |||||
using Microsoft.EntityFrameworkCore; | |||||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||||
using Microsoft.EntityFrameworkCore.Metadata; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
[DbContext(typeof(OrderingDbContext))] | |||||
[Migration("20161011040943_Migration2")] | |||||
partial class Migration2 | |||||
{ | |||||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||||
{ | |||||
modelBuilder | |||||
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431") | |||||
.HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") | |||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => | |||||
{ | |||||
b.Property<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); | |||||
}); | |||||
} | |||||
} | |||||
} |
@ -1,24 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
public partial class Migration2 : Migration | |||||
{ | |||||
protected override void Up(MigrationBuilder migrationBuilder) | |||||
{ | |||||
migrationBuilder.AddColumn<string>( | |||||
name: "ProductName", | |||||
table: "OrderItem", | |||||
nullable: true); | |||||
} | |||||
protected override void Down(MigrationBuilder migrationBuilder) | |||||
{ | |||||
migrationBuilder.DropColumn( | |||||
name: "ProductName", | |||||
table: "OrderItem"); | |||||
} | |||||
} | |||||
} |
@ -1,123 +0,0 @@ | |||||
using System; | |||||
using Microsoft.EntityFrameworkCore; | |||||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||||
using Microsoft.EntityFrameworkCore.Metadata; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
[DbContext(typeof(OrderingDbContext))] | |||||
[Migration("20161011041130_Migration3")] | |||||
partial class Migration3 | |||||
{ | |||||
protected override void BuildTargetModel(ModelBuilder modelBuilder) | |||||
{ | |||||
modelBuilder | |||||
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431") | |||||
.HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") | |||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => | |||||
{ | |||||
b.Property<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); | |||||
}); | |||||
} | |||||
} | |||||
} |
@ -1,19 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
public partial class Migration3 : Migration | |||||
{ | |||||
protected override void Up(MigrationBuilder migrationBuilder) | |||||
{ | |||||
} | |||||
protected override void Down(MigrationBuilder migrationBuilder) | |||||
{ | |||||
} | |||||
} | |||||
} |
@ -1,122 +0,0 @@ | |||||
using System; | |||||
using Microsoft.EntityFrameworkCore; | |||||
using Microsoft.EntityFrameworkCore.Infrastructure; | |||||
using Microsoft.EntityFrameworkCore.Metadata; | |||||
using Microsoft.EntityFrameworkCore.Migrations; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
namespace Ordering.API.Migrations | |||||
{ | |||||
[DbContext(typeof(OrderingDbContext))] | |||||
partial class OrderingDbContextModelSnapshot : ModelSnapshot | |||||
{ | |||||
protected override void BuildModel(ModelBuilder modelBuilder) | |||||
{ | |||||
modelBuilder | |||||
.HasAnnotation("ProductVersion", "1.0.0-rtm-21431") | |||||
.HasAnnotation("Relational:Sequence:shared.OrderSequences", "'OrderSequences', 'shared', '1001', '1', '', '', 'Int32', 'False'") | |||||
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); | |||||
modelBuilder.Entity("Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel.Address", b => | |||||
{ | |||||
b.Property<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,15 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Commands | |||||
{ | |||||
using MediatR; | |||||
public class CancelOrderRequest | |||||
: IAsyncRequest<bool> | |||||
{ | |||||
public int OrderId { get; private set; } | |||||
public CancelOrderRequest(int orderId) | |||||
{ | |||||
OrderId = orderId; | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,15 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Commands | |||||
{ | |||||
using MediatR; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
public class CancelOrderRequestHandler | |||||
: IAsyncRequestHandler<CancelOrderRequest, bool> | |||||
{ | |||||
public Task<bool> Handle(CancelOrderRequest message) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,15 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Commands | |||||
{ | |||||
using MediatR; | |||||
using System; | |||||
using System.Threading.Tasks; | |||||
public class NewOrderREquestHandler | |||||
: IAsyncRequestHandler<NewOrderRequest, bool> | |||||
{ | |||||
public Task<bool> Handle(NewOrderRequest message) | |||||
{ | |||||
throw new NotImplementedException(); | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,12 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Commands | |||||
{ | |||||
using MediatR; | |||||
public class NewOrderRequest | |||||
:IAsyncRequest<bool> | |||||
{ | |||||
public NewOrderRequest() | |||||
{ | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,19 @@ | |||||
<?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>4193caa3-a1c3-4818-a06f-a2d85fde77e7</ProjectGuid> | |||||
<RootNamespace>Microsoft.eShopOnContainers.Services.Ordering.Application</RootNamespace> | |||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | |||||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | |||||
<TargetFrameworkVersion>v4.5.1</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.Application")] | |||||
[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("4193caa3-a1c3-4818-a06f-a2d85fde77e7")] |
@ -0,0 +1,11 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Queries | |||||
{ | |||||
using System.Threading.Tasks; | |||||
public interface IOrderQueries | |||||
{ | |||||
Task<dynamic> GetOrder(int id); | |||||
Task<dynamic> GetPendingOrders(); | |||||
} | |||||
} |
@ -0,0 +1,13 @@ | |||||
| |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Application.Queries | |||||
{ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
public class OrderQueries | |||||
{ | |||||
} | |||||
} |
@ -0,0 +1,16 @@ | |||||
{ | |||||
"version": "1.0.0-*", | |||||
"dependencies": { | |||||
"NETStandard.Library": "1.6.0", | |||||
"MediatR": "2.1.0", | |||||
"System.Dynamic.Runtime": "4.0.11", | |||||
"Microsoft.CSharp": "4.0.1" | |||||
}, | |||||
"frameworks": { | |||||
"netstandard1.6": { | |||||
"imports": "dnxcore50" | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,29 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain | |||||
{ | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
using System; | |||||
public class Address | |||||
: Entity | |||||
{ | |||||
public String Street { get; private set; } | |||||
public String City { get; private set; } | |||||
public String State { get; private set; } | |||||
public String StateCode { get; private set; } | |||||
public String Country { get; private set; } | |||||
public String CountryCode { get; private set; } | |||||
public String ZipCode { get; private set; } | |||||
public double Latitude { get; private set; } | |||||
public double Longitude { get; private set; } | |||||
protected Address() { } | |||||
} | |||||
} |
@ -1,49 +0,0 @@ | |||||
using System; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel | |||||
{ | |||||
public class Buyer : Entity, IAggregateRoot | |||||
{ | |||||
public Buyer(Guid buyerId, string name, string lastName, string email, Address address, string phoneNumber) | |||||
{ | |||||
this.Id = buyerId; | |||||
this.Name = name; | |||||
this.LastName = lastName; | |||||
this.Email = email; | |||||
this.Address = address; | |||||
this.PhoneNumber = phoneNumber; | |||||
} | |||||
public virtual string Name | |||||
{ | |||||
get; | |||||
private set; | |||||
} | |||||
public virtual string LastName | |||||
{ | |||||
get; | |||||
private set; | |||||
} | |||||
public virtual string Email | |||||
{ | |||||
get; | |||||
private set; | |||||
} | |||||
public virtual Address Address | |||||
{ | |||||
get; | |||||
private set; | |||||
} | |||||
public virtual string PhoneNumber | |||||
{ | |||||
get; | |||||
private set; | |||||
} | |||||
} | |||||
} |
@ -1,70 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel | |||||
{ | |||||
public class Address : ValueObject<Address> | |||||
{ | |||||
public Address(string street, | |||||
string city, | |||||
string state, | |||||
string stateCode, | |||||
string country, | |||||
string countryCode, | |||||
string zipCode, | |||||
double latitude = 0, | |||||
double longitude = 0 | |||||
) | |||||
{ | |||||
if (street == null) | |||||
throw new ArgumentNullException("street"); | |||||
if (city == null) | |||||
throw new ArgumentNullException("city"); | |||||
if (state == null) | |||||
throw new ArgumentNullException("state"); | |||||
if (stateCode == null) | |||||
throw new ArgumentNullException("stateCode"); | |||||
if (country == null) | |||||
throw new ArgumentNullException("country"); | |||||
if (countryCode == null) | |||||
throw new ArgumentNullException("countryCode"); | |||||
if (zipCode == null) | |||||
throw new ArgumentNullException("zipCode"); | |||||
//Generate the ID guid - Remove this when EF Core supports ValueObjects | |||||
// https://github.com/aspnet/EntityFramework/issues/246 | |||||
this.Id = Guid.NewGuid(); | |||||
this.Street = street; | |||||
this.City = city; | |||||
this.State = state; | |||||
this.StateCode = stateCode; | |||||
this.Country = country; | |||||
this.CountryCode = countryCode; | |||||
this.ZipCode = zipCode; | |||||
this.Latitude = latitude; | |||||
this.Longitude = longitude; | |||||
} | |||||
//Infrastructure requisite - Parameterless constructor needed by EF | |||||
Address() { } | |||||
public virtual String Street { get; private set; } | |||||
public virtual String City { get; private set; } | |||||
public virtual String State { get; private set; } | |||||
public virtual String StateCode { get; private set; } | |||||
public virtual String Country { get; private set; } | |||||
public virtual String CountryCode { get; private set; } | |||||
public virtual String ZipCode { get; private set; } | |||||
public virtual double Latitude { get; private set; } | |||||
public virtual double Longitude { get; private set; } | |||||
} | |||||
} |
@ -1,112 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel | |||||
{ | |||||
public class Order : Entity, IAggregateRoot | |||||
{ | |||||
public Order(Guid buyerId, Address shippingAddress, Address billingAddress) | |||||
: this(buyerId, shippingAddress, billingAddress, DateTime.UtcNow) | |||||
{ | |||||
} | |||||
public Order(Guid buyerId, Address shippingAddress, Address billingAddress, DateTime orderDate) | |||||
{ | |||||
this.BuyerId = buyerId; | |||||
this.ShippingAddress = shippingAddress; | |||||
this.BillingAddress = billingAddress; | |||||
this.OrderDate = orderDate; | |||||
this.Status = OrderStatus.New; | |||||
} | |||||
//Infrastructure requisite - Parameterless constructor needed by EF | |||||
Order() { } | |||||
//Order ID comes derived from the Entity base class | |||||
List<OrderItem> _orderItems; | |||||
public virtual List<OrderItem> OrderItems | |||||
{ | |||||
get | |||||
{ | |||||
if (_orderItems == null) | |||||
_orderItems = new List<OrderItem>(); | |||||
return _orderItems; | |||||
} | |||||
private set | |||||
{ | |||||
_orderItems = value; | |||||
} | |||||
} | |||||
public string OrderNumber | |||||
{ | |||||
get | |||||
{ | |||||
return string.Format("{0}/{1}-{2}", OrderDate.Year, OrderDate.Month, SequenceNumber); | |||||
} | |||||
} | |||||
public int SequenceNumber { get; set; } | |||||
public virtual Guid BuyerId { get; private set; } | |||||
public virtual Address ShippingAddress { get; private set; } | |||||
public virtual Address BillingAddress { get; private set; } | |||||
public virtual DateTime OrderDate { get; private set; } | |||||
public virtual OrderStatus Status { get; private set; } | |||||
//////////////////////////////////////////////////////////////////////////////////////// | |||||
//Domain Rules and Logic in Order Aggregate-Root (Sample of a "NO ANEMIC DOMAIN MODEL" ) | |||||
//////////////////////////////////////////////////////////////////////////////////////// | |||||
public OrderItem AddNewOrderItem(Guid productId, int quantity, decimal unitPrice, decimal discount) | |||||
{ | |||||
//check preconditions | |||||
if (productId == Guid.Empty) | |||||
throw new ArgumentNullException("productId"); | |||||
if (quantity <= 0) | |||||
{ | |||||
throw new ArgumentException("The quantity of Product in an Order cannot be equal or less than cero"); | |||||
} | |||||
//check discount values | |||||
if (discount < 0) | |||||
discount = 0; | |||||
if (discount > 100) | |||||
discount = 100; | |||||
//create new order line | |||||
var newOrderItem = new OrderItem() | |||||
{ | |||||
OrderId = this.Id, | |||||
ProductId = productId, | |||||
Quantity = quantity, | |||||
FulfillmentRemaining = quantity, | |||||
Discount = discount, | |||||
UnitPrice = unitPrice | |||||
}; | |||||
//set identity | |||||
newOrderItem.GenerateNewIdentity(); | |||||
//add order item | |||||
this.OrderItems.Add(newOrderItem); | |||||
//return added orderline | |||||
return newOrderItem; | |||||
} | |||||
} | |||||
} |
@ -1,33 +0,0 @@ | |||||
using System; | |||||
using System.Runtime.Serialization; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel | |||||
{ | |||||
public class OrderItem : Entity | |||||
{ | |||||
public OrderItem() { } // Infrastructure. EF might need a plain constructor. Do not use. | |||||
//NOTE: The OrderItem Id (Id) comes from the Entity base class | |||||
public Guid ProductId { get; set; } | |||||
public Guid OrderId { get; set; } | |||||
public decimal UnitPrice { get; set; } | |||||
public string ProductName { get; set; } | |||||
public int Quantity { get; set; } | |||||
public decimal Discount { get; set; } | |||||
public int FulfillmentRemaining { get; set; } | |||||
public override string ToString() | |||||
{ | |||||
return String.Format("Product Id: {0}, Quantity: {1}, Fulfillment Remaing: {2}", this.Id, this.Quantity, this.FulfillmentRemaining); | |||||
} | |||||
} | |||||
} |
@ -1,18 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel | |||||
{ | |||||
public enum OrderStatus | |||||
{ | |||||
Unknown, | |||||
New, | |||||
Submitted, | |||||
InProcess, | |||||
Backordered, | |||||
Shipped, | |||||
Canceled, | |||||
} | |||||
} |
@ -0,0 +1,12 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain | |||||
{ | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
public class Buyer | |||||
:Entity,IAggregateRoot | |||||
{ | |||||
public string FullName { get; private set; } | |||||
protected Buyer() { } | |||||
} | |||||
} |
@ -1,15 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts | |||||
{ | |||||
public interface IBuyerRepository : IRepository | |||||
{ | |||||
//TBD - To define Specific Actions Not In Base Repo | |||||
} | |||||
} |
@ -1,20 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts | |||||
{ | |||||
public interface IOrderRepository : IRepository | |||||
{ | |||||
void Add(Order order); | |||||
void Update(Order order); | |||||
Task Remove(Guid id); | |||||
Task<Order> FindAsync(Guid id); | |||||
} | |||||
} | |||||
@ -0,0 +1,30 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain | |||||
{ | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
public class Order | |||||
:Entity, IAggregateRoot | |||||
{ | |||||
public int BuyerId { get; private set; } | |||||
public Buyer Buyer { get; private set; } | |||||
public DateTime OrderDate { get; private set; } | |||||
public OrderStatus Status { get; private set; } | |||||
public ICollection<OrderItem> OrderItems { get; set; } | |||||
public int ShippingAddressId { get; private set; } | |||||
public Address ShippingAddress { get; private set; } | |||||
public int BillingAddressId { get; private set; } | |||||
public Address BillingAddress { get; private set; } | |||||
protected Order() { } | |||||
} | |||||
} |
@ -0,0 +1,25 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain | |||||
{ | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
public class OrderItem | |||||
:Entity | |||||
{ | |||||
public int ProductId { get; private set; } | |||||
public string ProductName { get; private set; } | |||||
public int OrderId { get; private set; } | |||||
public decimal UnitPrice { get; private set; } | |||||
public decimal Discount { get; private set; } | |||||
public int Units { get; private set; } | |||||
protected OrderItem() | |||||
{ | |||||
} | |||||
} | |||||
} |
@ -0,0 +1,59 @@ | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain | |||||
{ | |||||
using SeedWork; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
public class OrderStatus | |||||
:Entity | |||||
{ | |||||
public string Name { get; private set; } | |||||
public static OrderStatus New = new OrderStatus(1, nameof(New).ToLowerInvariant()); | |||||
public static OrderStatus Submitted = new OrderStatus(1, nameof(Submitted).ToLowerInvariant()); | |||||
public static OrderStatus InProcess = new OrderStatus(1, nameof(InProcess).ToLowerInvariant()); | |||||
public static OrderStatus Shipped = new OrderStatus(1, nameof(Shipped).ToLowerInvariant()); | |||||
public static OrderStatus Canceled = new OrderStatus(1, nameof(Canceled).ToLowerInvariant()); | |||||
protected OrderStatus() | |||||
{ | |||||
} | |||||
public OrderStatus(int id, string name) | |||||
{ | |||||
Id = id; | |||||
Name = name; | |||||
} | |||||
public static IEnumerable<OrderStatus> List() | |||||
{ | |||||
return new[] { New, Submitted, InProcess, Shipped, Canceled }; | |||||
} | |||||
public static OrderStatus FromName(string name) | |||||
{ | |||||
var state = List() | |||||
.SingleOrDefault(s => String.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase)); | |||||
if (state == null) | |||||
{ | |||||
throw new ArgumentException($"Possible values for OrderStatus: {String.Join(",", List().Select(s => s.Name))}"); | |||||
} | |||||
return state; | |||||
} | |||||
public static OrderStatus From(int id) | |||||
{ | |||||
var state = List().SingleOrDefault(s => s.Id == id); | |||||
if (state == null) | |||||
{ | |||||
throw new ArgumentException($"Possible values for OrderStatus: {String.Join(",", List().Select(s => s.Name))}"); | |||||
} | |||||
return state; | |||||
} | |||||
} | |||||
} |
@ -1,47 +0,0 @@ | |||||
using System; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork | |||||
{ | |||||
internal static class IdentityGenerator | |||||
{ | |||||
/// <summary> | |||||
/// This algorithm generates secuential GUIDs across system boundaries, ideal for databases | |||||
/// </summary> | |||||
/// <returns></returns> | |||||
public static Guid NewSequentialGuid() | |||||
{ | |||||
byte[] uid = Guid.NewGuid().ToByteArray(); | |||||
byte[] binDate = BitConverter.GetBytes(DateTime.UtcNow.Ticks); | |||||
byte[] secuentialGuid = new byte[uid.Length]; | |||||
secuentialGuid[0] = uid[0]; | |||||
secuentialGuid[1] = uid[1]; | |||||
secuentialGuid[2] = uid[2]; | |||||
secuentialGuid[3] = uid[3]; | |||||
secuentialGuid[4] = uid[4]; | |||||
secuentialGuid[5] = uid[5]; | |||||
secuentialGuid[6] = uid[6]; | |||||
// set the first part of the 8th byte to '1100' so | |||||
// later we'll be able to validate it was generated by us | |||||
secuentialGuid[7] = (byte)(0xc0 | (0xf & uid[7])); | |||||
// the last 8 bytes are sequential, | |||||
// it minimizes index fragmentation | |||||
// to a degree as long as there are not a large | |||||
// number of Secuential-Guids generated per millisecond | |||||
secuentialGuid[9] = binDate[0]; | |||||
secuentialGuid[8] = binDate[1]; | |||||
secuentialGuid[15] = binDate[2]; | |||||
secuentialGuid[14] = binDate[3]; | |||||
secuentialGuid[13] = binDate[4]; | |||||
secuentialGuid[12] = binDate[5]; | |||||
secuentialGuid[11] = binDate[6]; | |||||
secuentialGuid[10] = binDate[7]; | |||||
return new Guid(secuentialGuid); | |||||
} | |||||
} | |||||
} |
@ -1,24 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries | |||||
{ | |||||
//The OrderingQueries Contracts/Interfaces could be moved to a third assembly | |||||
//We're not putting this contract in the Domain layer assembly because | |||||
//queries/joins are just Application's needs and should not be limited | |||||
//to the Domain Model restrictions (Aggregates and Repositories restrictions). | |||||
// | |||||
//In this case we're using the same EF Context but another good approach | |||||
//is also to simply use SQL sentences for the queries with any Micro-ORM (like Dapper) or even just ADO.NET | |||||
// | |||||
//The point is that Queries are IDEMPOTENT and don't need to commit to DDD Domain restrictions | |||||
//so could be implemented in a completely orthogonal way in regards the Domain Layer (à la CQRS) | |||||
public interface IOrderdingQueries | |||||
{ | |||||
Task<dynamic> GetAllOrdersIncludingValueObjectsAndChildEntities(); | |||||
Task<dynamic> GetOrderById(Guid orderId); | |||||
} | |||||
} |
@ -1,98 +0,0 @@ | |||||
| |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.EntityFrameworkCore; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.SqlData.Queries | |||||
{ | |||||
//In this case, for the Application queries, we're using the same EF Context but another good approach | |||||
//is also to simply use SQL sentences for the queries with any Micro-ORM (like Dapper) or even just ADO.NET | |||||
// | |||||
//The point is that Queries are IDEMPOTENT and don't need to commit to DDD Domain restrictions | |||||
//so could be implemented in a completely orthogonal way in regards the Domain Layer (à la CQRS) | |||||
public class OrderingQueries : IOrderdingQueries | |||||
{ | |||||
private OrderingDbContext _dbContext; | |||||
public OrderingQueries(OrderingDbContext orderingDbContext) | |||||
{ | |||||
_dbContext = orderingDbContext; | |||||
} | |||||
public async Task<dynamic> GetAllOrdersIncludingValueObjectsAndChildEntities() | |||||
{ | |||||
var orders = await _dbContext.Orders | |||||
.Include(o => o.ShippingAddress) | |||||
.Include(o => o.BillingAddress) | |||||
.Include(o => o.OrderItems) | |||||
.ToListAsync<Order>(); | |||||
// Dynamically generated a Response-Model that includes only the fields you need in the response. | |||||
// This keeps the JSON response minimal. | |||||
// Could also use var | |||||
dynamic response = orders.Select(o => new | |||||
{ | |||||
id = o.Id, | |||||
orderNumber = o.OrderNumber, | |||||
buyerId = o.BuyerId, | |||||
orderDate = o.OrderDate, | |||||
status = o.Status, | |||||
shippingAddress = o.ShippingAddress, | |||||
billingAddress = o.BillingAddress, | |||||
orderItems = o.OrderItems.Select(i => new | |||||
{ | |||||
id = i.Id, | |||||
productId = i.ProductId, | |||||
unitPrice = i.UnitPrice, | |||||
quantity = i.Quantity, | |||||
discount = i.Discount | |||||
} | |||||
) | |||||
}); | |||||
return response; | |||||
} | |||||
public async Task<dynamic> GetOrderById(Guid orderId) | |||||
{ | |||||
var order = await _dbContext.Orders | |||||
.Include(o => o.ShippingAddress) | |||||
.Include(o => o.BillingAddress) | |||||
.Include(o => o.OrderItems) | |||||
.Where(o => o.Id == orderId) | |||||
.SingleOrDefaultAsync<Order>(); | |||||
// Dynamically generated a Response-Model that includes only the fields you need in the response. | |||||
// This keeps the JSON response minimal. | |||||
// Could also use var | |||||
dynamic response = new | |||||
{ | |||||
id = order.Id, | |||||
orderNumber = order.OrderNumber, | |||||
buyerId = order.BuyerId, | |||||
orderDate = order.OrderDate, | |||||
status = order.Status, | |||||
shippingAddress = order.ShippingAddress, | |||||
billingAddress = order.BillingAddress, | |||||
orderItems = order.OrderItems.Select(i => new | |||||
{ | |||||
id = i.Id, | |||||
productId = i.ProductId, | |||||
unitPrice = i.UnitPrice, | |||||
quantity = i.Quantity, | |||||
discount = i.Discount | |||||
} | |||||
) | |||||
}; | |||||
return response; | |||||
} | |||||
} | |||||
} |
@ -1,51 +0,0 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.Threading.Tasks; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.AggregatesModel; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.Contracts; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.SqlData.UnitOfWork; | |||||
using Microsoft.eShopOnContainers.Services.Ordering.Domain.SeedWork; | |||||
using Microsoft.EntityFrameworkCore; | |||||
namespace Microsoft.eShopOnContainers.Services.Ordering.SqlData.Repositories | |||||
{ | |||||
//1:1 relationship between Repository and Aggregate (i.e. OrderRepository and Order) | |||||
public class OrderRepository : IOrderRepository | |||||
{ | |||||
private readonly OrderingDbContext _context; | |||||
public IUnitOfWork UnitOfWork => _context; | |||||
public OrderRepository(OrderingDbContext orderingDbContext) | |||||
{ | |||||
_context = orderingDbContext; | |||||
} | |||||
public void Add(Order order) | |||||
{ | |||||
_context.Orders.Add(order); | |||||
} | |||||
public void Update(Order order) | |||||
{ | |||||
_context.Orders.Update(order); | |||||
} | |||||
public async Task Remove(Guid orderId) | |||||
{ | |||||
var orderToRemove = await _context.Orders.Where(o => o.Id == orderId).SingleOrDefaultAsync(); | |||||
_context.Orders.Remove(orderToRemove); | |||||
} | |||||
public async Task<Order> FindAsync(Guid id) | |||||
{ | |||||
if (id != Guid.Empty) | |||||
return await _context.Set<Order>().FirstOrDefaultAsync(o => o.Id == id); | |||||
else | |||||
return null; | |||||
} | |||||
} | |||||
} |