committed by
GitHub
16 changed files with 923 additions and 17 deletions
@ -0,0 +1,70 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
|
|||
namespace EShopOnAbp.OrderingService; |
|||
|
|||
// https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/src/Services/Ordering/Ordering.Domain/SeedWork/Enumeration.cs
|
|||
public abstract class Enumeration : IComparable |
|||
{ |
|||
public string Name { get; private set; } |
|||
|
|||
public int Id { get; private set; } |
|||
|
|||
protected Enumeration(int id, string name) => (Id, Name) = (id, name); |
|||
|
|||
public override string ToString() => Name; |
|||
|
|||
public static IEnumerable<T> GetAll<T>() where T : Enumeration => |
|||
typeof(T).GetFields(BindingFlags.Public | |
|||
BindingFlags.Static | |
|||
BindingFlags.DeclaredOnly) |
|||
.Select(f => f.GetValue(null)) |
|||
.Cast<T>(); |
|||
|
|||
public override bool Equals(object obj) |
|||
{ |
|||
if (obj is not Enumeration otherValue) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
var typeMatches = GetType().Equals(obj.GetType()); |
|||
var valueMatches = Id.Equals(otherValue.Id); |
|||
|
|||
return typeMatches && valueMatches; |
|||
} |
|||
|
|||
public override int GetHashCode() => Id.GetHashCode(); |
|||
|
|||
public static int AbsoluteDifference(Enumeration firstValue, Enumeration secondValue) |
|||
{ |
|||
var absoluteDifference = Math.Abs(firstValue.Id - secondValue.Id); |
|||
return absoluteDifference; |
|||
} |
|||
|
|||
public static T FromValue<T>(int value) where T : Enumeration |
|||
{ |
|||
var matchingItem = Parse<T, int>(value, "value", item => item.Id == value); |
|||
return matchingItem; |
|||
} |
|||
|
|||
public static T FromDisplayName<T>(string displayName) where T : Enumeration |
|||
{ |
|||
var matchingItem = Parse<T, string>(displayName, "display name", item => item.Name == displayName); |
|||
return matchingItem; |
|||
} |
|||
|
|||
private static T Parse<T, K>(K value, string description, Func<T, bool> predicate) where T : Enumeration |
|||
{ |
|||
var matchingItem = GetAll<T>().FirstOrDefault(predicate); |
|||
|
|||
if (matchingItem == null) |
|||
throw new InvalidOperationException($"'{value}' is not a valid {description} in {typeof(T)}"); |
|||
|
|||
return matchingItem; |
|||
} |
|||
|
|||
public int CompareTo(object other) => Id.CompareTo(((Enumeration) other).Id); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace EShopOnAbp.OrderingService.Orders; |
|||
|
|||
public static class OrderConstants |
|||
{ |
|||
public const int OrderDescriptionMaxLength = 1024; |
|||
public const int OrderStatusNameMaxLength = 256; |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace EShopOnAbp.OrderingService.Buyers; |
|||
|
|||
public class Buyer : AggregateRoot<Guid> |
|||
{ |
|||
public string UserName { get; private set; } |
|||
public string Name { get; private set; } |
|||
public string PaymentId { get; private set; } |
|||
|
|||
private Buyer() |
|||
{ |
|||
} |
|||
|
|||
public Buyer(Guid id, [NotNull] string userName, [NotNull] string name, [NotNull] string paymentId) : base(id) |
|||
{ |
|||
UserName = Check.NotNullOrEmpty(userName, nameof(userName)); |
|||
Name = Check.NotNullOrEmpty(name, nameof(name)); |
|||
PaymentId = Check.NotNullOrEmpty(paymentId, nameof(paymentId)); |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.Domain.Values; |
|||
|
|||
namespace EShopOnAbp.OrderingService.Orders; |
|||
|
|||
public class Address : ValueObject |
|||
{ |
|||
public string Description { get; private set; } |
|||
public string Street { get; private set; } |
|||
public string City { get; private set; } |
|||
public string Country { get; private set; } |
|||
public string ZipCode { get; private set; } |
|||
|
|||
private Address() |
|||
{ |
|||
} |
|||
|
|||
public Address(string street, string city, string description, string country, string zipcode) |
|||
{ |
|||
Street = street; |
|||
City = city; |
|||
Description = description; |
|||
Country = country; |
|||
ZipCode = zipcode; |
|||
} |
|||
|
|||
protected override IEnumerable<object> GetAtomicValues() |
|||
{ |
|||
yield return Street; |
|||
yield return City; |
|||
yield return Description; |
|||
yield return Country; |
|||
yield return ZipCode; |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace EShopOnAbp.OrderingService.Orders; |
|||
|
|||
public class Order : AggregateRoot<Guid> |
|||
{ |
|||
private int _orderStatusId; |
|||
public DateTime OrderDate { get; private set; } |
|||
public Guid? BuyerId { get; private set; } |
|||
public string Description { get; private set; } |
|||
public string PaymentMethodToken { get; private set; } // PaymentId or token for validation
|
|||
public Address Address { get; private set; } |
|||
public OrderStatus OrderStatus { get; private set; } |
|||
public List<OrderItem> OrderItems { get; private set; } |
|||
|
|||
private Order() |
|||
{ |
|||
} |
|||
|
|||
public Order(Guid id, Address address, Guid? buyerId = null, string paymentMethodToken = null) : base() |
|||
{ |
|||
_orderStatusId = OrderStatus.Submitted.Id; |
|||
OrderDate = DateTime.UtcNow; |
|||
Address = address; |
|||
BuyerId = buyerId; |
|||
PaymentMethodToken = paymentMethodToken; |
|||
OrderItems = new List<OrderItem>(); |
|||
} |
|||
|
|||
public void AddOrderItem(Guid productId, string productName, decimal unitPrice, decimal discount, string pictureUrl, |
|||
int units = 1) |
|||
{ |
|||
var existingOrderForProduct = OrderItems.SingleOrDefault(o => o.ProductId == productId); |
|||
|
|||
if (existingOrderForProduct != null) |
|||
{ |
|||
if (discount > existingOrderForProduct.Discount) |
|||
{ |
|||
existingOrderForProduct.SetNewDiscount(discount); |
|||
} |
|||
|
|||
existingOrderForProduct.AddUnits(units); |
|||
} |
|||
else |
|||
{ |
|||
var orderItem = new OrderItem(productId, productName, unitPrice, discount, pictureUrl, units); |
|||
OrderItems.Add(orderItem); |
|||
} |
|||
} |
|||
|
|||
public decimal GetTotal() |
|||
{ |
|||
return OrderItems.Sum(o => o.Units * o.UnitPrice); |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace EShopOnAbp.OrderingService.Orders; |
|||
|
|||
public class OrderItem : Entity<Guid> |
|||
{ |
|||
public string ProductName { get; private set; } |
|||
public string PictureUrl { get; private set; } |
|||
public decimal UnitPrice { get; private set; } |
|||
public decimal Discount { get; private set; } |
|||
public int Units { get; private set; } |
|||
public Guid ProductId { get; private set; } |
|||
|
|||
protected OrderItem() { } |
|||
|
|||
public OrderItem(Guid productId, [NotNull]string productName, decimal unitPrice, decimal discount, [CanBeNull]string pictureUrl, int units = 1) |
|||
{ |
|||
if (units <= 0) |
|||
{ |
|||
throw new BusinessException(OrderingServiceErrorCodes.InvalidUnits); |
|||
} |
|||
|
|||
if ((unitPrice * units) < discount) |
|||
{ |
|||
throw new BusinessException(OrderingServiceErrorCodes.InvalidTotalForDiscount); |
|||
} |
|||
|
|||
ProductId = productId; |
|||
ProductName = Check.NotNullOrEmpty(productName, nameof(productName)); |
|||
UnitPrice = unitPrice; |
|||
Discount = discount; |
|||
Units = units; |
|||
PictureUrl = pictureUrl; |
|||
} |
|||
|
|||
public void SetNewDiscount(decimal discount) |
|||
{ |
|||
if (discount < 0) |
|||
{ |
|||
throw new BusinessException(OrderingServiceErrorCodes.InvalidDiscount); |
|||
} |
|||
|
|||
Discount = discount; |
|||
} |
|||
|
|||
public void AddUnits(int units) |
|||
{ |
|||
if (units < 0) |
|||
{ |
|||
throw new BusinessException(OrderingServiceErrorCodes.InvalidUnits); |
|||
} |
|||
|
|||
Units += units; |
|||
} |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Volo.Abp; |
|||
|
|||
namespace EShopOnAbp.OrderingService.Orders; |
|||
|
|||
public class OrderStatus: Enumeration |
|||
{ |
|||
public static OrderStatus Submitted = new OrderStatus(1, nameof(Submitted).ToLowerInvariant()); |
|||
public static OrderStatus AwaitingValidation = new OrderStatus(2, nameof(AwaitingValidation).ToLowerInvariant()); |
|||
public static OrderStatus StockConfirmed = new OrderStatus(3, nameof(StockConfirmed).ToLowerInvariant()); |
|||
public static OrderStatus Paid = new OrderStatus(4, nameof(Paid).ToLowerInvariant()); |
|||
public static OrderStatus Shipped = new OrderStatus(5, nameof(Shipped).ToLowerInvariant()); |
|||
public static OrderStatus Cancelled = new OrderStatus(6, nameof(Cancelled).ToLowerInvariant()); |
|||
|
|||
public OrderStatus(int id, string name) |
|||
: base(id, name) |
|||
{ |
|||
} |
|||
|
|||
public static IEnumerable<OrderStatus> List() => |
|||
new[] { Submitted, AwaitingValidation, StockConfirmed, Paid, Shipped, Cancelled }; |
|||
|
|||
public static OrderStatus FromName(string name) |
|||
{ |
|||
var state = List() |
|||
.SingleOrDefault(s => String.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase)); |
|||
|
|||
if (state == null) |
|||
{ |
|||
throw new BusinessException(OrderingServiceErrorCodes.OrderingStatusNotFound) |
|||
.WithData("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 BusinessException(OrderingServiceErrorCodes.OrderingStatusNotFound) |
|||
.WithData("OrderStatus", String.Join(",", List().Select(s => s.Name))); |
|||
} |
|||
|
|||
return state; |
|||
} |
|||
} |
|||
@ -0,0 +1,215 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using EShopOnAbp.OrderingService.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace EShopOnAbp.OrderingService.Migrations |
|||
{ |
|||
[DbContext(typeof(OrderingServiceDbContext))] |
|||
[Migration("20211228131200_Added_Order_and_Buyer_Aggregates")] |
|||
partial class Added_Order_and_Buyer_Aggregates |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql) |
|||
.HasAnnotation("ProductVersion", "6.0.0") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 63); |
|||
|
|||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); |
|||
|
|||
modelBuilder.Entity("EShopOnAbp.OrderingService.Buyers.Buyer", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("character varying(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("text") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasColumnType("text"); |
|||
|
|||
b.Property<string>("PaymentId") |
|||
.IsRequired() |
|||
.HasColumnType("text"); |
|||
|
|||
b.Property<string>("UserName") |
|||
.IsRequired() |
|||
.HasColumnType("text"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("Buyers", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<Guid?>("BuyerId") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("character varying(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<string>("Description") |
|||
.HasMaxLength(1024) |
|||
.HasColumnType("character varying(1024)"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("text") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<DateTime>("OrderDate") |
|||
.HasColumnType("timestamp with time zone"); |
|||
|
|||
b.Property<string>("PaymentMethodToken") |
|||
.HasColumnType("text"); |
|||
|
|||
b.Property<int>("_orderStatusId") |
|||
.HasColumnType("integer") |
|||
.HasColumnName("OrderStatusId"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("BuyerId"); |
|||
|
|||
b.HasIndex("Id"); |
|||
|
|||
b.HasIndex("_orderStatusId"); |
|||
|
|||
b.ToTable("Orders", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<decimal>("Discount") |
|||
.HasColumnType("numeric"); |
|||
|
|||
b.Property<Guid>("OrderId") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<string>("PictureUrl") |
|||
.HasColumnType("text"); |
|||
|
|||
b.Property<Guid>("ProductId") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b.Property<string>("ProductName") |
|||
.IsRequired() |
|||
.HasColumnType("text"); |
|||
|
|||
b.Property<decimal>("UnitPrice") |
|||
.HasColumnType("numeric"); |
|||
|
|||
b.Property<int>("Units") |
|||
.HasColumnType("integer"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("OrderId"); |
|||
|
|||
b.ToTable("OrderItems", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderStatus", b => |
|||
{ |
|||
b.Property<int>("Id") |
|||
.HasColumnType("integer") |
|||
.HasDefaultValue(1); |
|||
|
|||
b.Property<string>("Name") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("character varying(256)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("OrderStatus", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b => |
|||
{ |
|||
b.HasOne("EShopOnAbp.OrderingService.Buyers.Buyer", null) |
|||
.WithMany() |
|||
.HasForeignKey("BuyerId"); |
|||
|
|||
b.HasOne("EShopOnAbp.OrderingService.Orders.OrderStatus", "OrderStatus") |
|||
.WithMany() |
|||
.HasForeignKey("_orderStatusId") |
|||
.OnDelete(DeleteBehavior.Cascade) |
|||
.IsRequired(); |
|||
|
|||
b.OwnsOne("EShopOnAbp.OrderingService.Orders.Address", "Address", b1 => |
|||
{ |
|||
b1.Property<Guid>("OrderId") |
|||
.HasColumnType("uuid"); |
|||
|
|||
b1.Property<string>("City") |
|||
.HasColumnType("text"); |
|||
|
|||
b1.Property<string>("Country") |
|||
.HasColumnType("text"); |
|||
|
|||
b1.Property<string>("Description") |
|||
.HasColumnType("text"); |
|||
|
|||
b1.Property<string>("Street") |
|||
.HasColumnType("text"); |
|||
|
|||
b1.Property<string>("ZipCode") |
|||
.HasColumnType("text"); |
|||
|
|||
b1.HasKey("OrderId"); |
|||
|
|||
b1.ToTable("Orders"); |
|||
|
|||
b1.WithOwner() |
|||
.HasForeignKey("OrderId"); |
|||
}); |
|||
|
|||
b.Navigation("Address"); |
|||
|
|||
b.Navigation("OrderStatus"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.OrderItem", b => |
|||
{ |
|||
b.HasOne("EShopOnAbp.OrderingService.Orders.Order", null) |
|||
.WithMany("OrderItems") |
|||
.HasForeignKey("OrderId") |
|||
.OnDelete(DeleteBehavior.Cascade) |
|||
.IsRequired(); |
|||
}); |
|||
|
|||
modelBuilder.Entity("EShopOnAbp.OrderingService.Orders.Order", b => |
|||
{ |
|||
b.Navigation("OrderItems"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,134 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace EShopOnAbp.OrderingService.Migrations |
|||
{ |
|||
public partial class Added_Order_and_Buyer_Aggregates : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.CreateTable( |
|||
name: "Buyers", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
UserName = table.Column<string>(type: "text", nullable: false), |
|||
Name = table.Column<string>(type: "text", nullable: false), |
|||
PaymentId = table.Column<string>(type: "text", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_Buyers", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OrderStatus", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<int>(type: "integer", nullable: false, defaultValue: 1), |
|||
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OrderStatus", x => x.Id); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "Orders", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
OrderDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), |
|||
BuyerId = table.Column<Guid>(type: "uuid", nullable: true), |
|||
Description = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true), |
|||
PaymentMethodToken = table.Column<string>(type: "text", nullable: true), |
|||
Address_Description = table.Column<string>(type: "text", nullable: true), |
|||
Address_Street = table.Column<string>(type: "text", nullable: true), |
|||
Address_City = table.Column<string>(type: "text", nullable: true), |
|||
Address_Country = table.Column<string>(type: "text", nullable: true), |
|||
Address_ZipCode = table.Column<string>(type: "text", nullable: true), |
|||
OrderStatusId = table.Column<int>(type: "integer", nullable: false), |
|||
ExtraProperties = table.Column<string>(type: "text", nullable: true), |
|||
ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_Orders", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_Orders_Buyers_BuyerId", |
|||
column: x => x.BuyerId, |
|||
principalTable: "Buyers", |
|||
principalColumn: "Id"); |
|||
table.ForeignKey( |
|||
name: "FK_Orders_OrderStatus_OrderStatusId", |
|||
column: x => x.OrderStatusId, |
|||
principalTable: "OrderStatus", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "OrderItems", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "uuid", nullable: false), |
|||
ProductName = table.Column<string>(type: "text", nullable: false), |
|||
PictureUrl = table.Column<string>(type: "text", nullable: true), |
|||
UnitPrice = table.Column<decimal>(type: "numeric", nullable: false), |
|||
Discount = table.Column<decimal>(type: "numeric", nullable: false), |
|||
Units = table.Column<int>(type: "integer", nullable: false), |
|||
ProductId = table.Column<Guid>(type: "uuid", nullable: false), |
|||
OrderId = table.Column<Guid>(type: "uuid", nullable: false) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_OrderItems", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_OrderItems_Orders_OrderId", |
|||
column: x => x.OrderId, |
|||
principalTable: "Orders", |
|||
principalColumn: "Id", |
|||
onDelete: ReferentialAction.Cascade); |
|||
}); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_OrderItems_OrderId", |
|||
table: "OrderItems", |
|||
column: "OrderId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_Orders_BuyerId", |
|||
table: "Orders", |
|||
column: "BuyerId"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_Orders_Id", |
|||
table: "Orders", |
|||
column: "Id"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_Orders_OrderStatusId", |
|||
table: "Orders", |
|||
column: "OrderStatusId"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "OrderItems"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "Orders"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "Buyers"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "OrderStatus"); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue