Add record types for DTOs. Update ordering DockerFiles to dotnet 5.0 base images.

This commit is contained in:
David Sanz 2020-12-15 16:32:07 +01:00
parent 94b1a0bed0
commit 90d70f8efc
7 changed files with 45 additions and 46 deletions

View File

@ -89,19 +89,19 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Commands
} }
public class OrderItemDTO public record OrderItemDTO
{ {
public int ProductId { get; set; } public int ProductId { get; init; }
public string ProductName { get; set; } public string ProductName { get; init; }
public decimal UnitPrice { get; set; } public decimal UnitPrice { get; init; }
public decimal Discount { get; set; } public decimal Discount { get; init; }
public int Units { get; set; } public int Units { get; init; }
public string PictureUrl { get; set; } public string PictureUrl { get; init; }
} }
} }
} }

View File

@ -4,7 +4,6 @@
using global::Ordering.API.Application.Models; using global::Ordering.API.Application.Models;
using MediatR; using MediatR;
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services; using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Services;
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure.Idempotency;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -42,10 +41,10 @@
} }
public class OrderDraftDTO public record OrderDraftDTO
{ {
public IEnumerable<OrderItemDTO> OrderItems { get; set; } public IEnumerable<OrderItemDTO> OrderItems { get; init; }
public decimal Total { get; set; } public decimal Total { get; init; }
public static OrderDraftDTO FromOrder(Order order) public static OrderDraftDTO FromOrder(Order order)
{ {

View File

@ -7,12 +7,12 @@ namespace Ordering.API.Application.Models
{ {
public class BasketItem public class BasketItem
{ {
public string Id { get; set; } public string Id { get; init; }
public int ProductId { get; set; } public int ProductId { get; init; }
public string ProductName { get; set; } public string ProductName { get; init; }
public decimal UnitPrice { get; set; } public decimal UnitPrice { get; init; }
public decimal OldUnitPrice { get; set; } public decimal OldUnitPrice { get; init; }
public int Quantity { get; set; } public int Quantity { get; init; }
public string PictureUrl { get; set; } public string PictureUrl { get; init; }
} }
} }

View File

@ -3,39 +3,39 @@ using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Queries
{ {
public class Orderitem public record Orderitem
{ {
public string productname { get; set; } public string productname { get; init; }
public int units { get; set; } public int units { get; init; }
public double unitprice { get; set; } public double unitprice { get; init; }
public string pictureurl { get; set; } public string pictureurl { get; init; }
} }
public class Order public record Order
{ {
public int ordernumber { get; set; } public int ordernumber { get; init; }
public DateTime date { get; set; } public DateTime date { get; init; }
public string status { get; set; } public string status { get; init; }
public string description { get; set; } public string description { get; init; }
public string street { get; set; } public string street { get; init; }
public string city { get; set; } public string city { get; init; }
public string zipcode { get; set; } public string zipcode { get; init; }
public string country { get; set; } public string country { get; init; }
public List<Orderitem> orderitems { get; set; } public List<Orderitem> orderitems { get; set; }
public decimal total { get; set; } public decimal total { get; set; }
} }
public class OrderSummary public record OrderSummary
{ {
public int ordernumber { get; set; } public int ordernumber { get; init; }
public DateTime date { get; set; } public DateTime date { get; init; }
public string status { get; set; } public string status { get; init; }
public double total { get; set; } public double total { get; init; }
} }
public class CardType public record CardType
{ {
public int Id { get; set; } public int Id { get; init; }
public string Name { get; set; } public string Name { get; init; }
} }
} }

View File

@ -1,8 +1,8 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src WORKDIR /src
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles

View File

@ -1,8 +1,8 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src WORKDIR /src
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles

View File

@ -1,8 +1,8 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src WORKDIR /src
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles # It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles