Server-side payment processing
As part of our server-side payment processing, we're going to actually persist the user's orders into the database, and to do that we need to make some changes to our data model. We have a couple of new entities to create, and a few minor tweaks for our existing ones. We'll also be looking at some of the new features introduced in EF Core 2.0 such as owned entity types.
Adding orders to the data model
The first and most obvious new entity we need is the Order
entity. Create a new Data/Entities/Order.cs
file with the following contents:
namespaceECommerce.Data.Entities { publicclassOrder { publicint Id { get; set; } publicint UserId { get; set; } publicDateTime Placed { get; set; } =DateTime.UtcNow; publicList<OrderItem> Items { get; set; } =newList<OrderItem>(); publicAddress DeliveryAddress { get; set; } publicPaymentStatus PaymentStatus { get; set; } = PaymentStatus.Pending; publicAppUser User { get; set; } ...