/
aprogrammer
/
blazor-workshop
Обзор
Документация
Войти
/
aprogrammer
/
blazor-workshop
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/BlazingPizza.Shared/Order.cs
35 строк
1 KB
Ed Charbeneau
Nullable (#365)
29 ноя 2023, 23:47
Не верифицирован
29 ноя 2023, 23:47
bb345a1
Код
Авторство
О чём код?
using System.Text.Json.Serialization; namespace BlazingPizza; public class Order { public int OrderId { get; set; } // Set by the server during POST public string? UserId { get; set; } public DateTime CreatedTime { get; set; } public Address DeliveryAddress { get; set; } = new Address(); // Set by server during POST public LatLong? DeliveryLocation { get; set; } public List<Pizza> Pizzas { get; set; } = new List<Pizza>(); public decimal GetTotalPrice() => Pizzas.Sum(p => p.GetTotalPrice()); public string GetFormattedTotalPrice() => GetTotalPrice().ToString("0.00"); } [JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Default, PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase)] [JsonSerializable(typeof(Order))] [JsonSerializable(typeof(OrderWithStatus))] [JsonSerializable(typeof(List<OrderWithStatus>))] [JsonSerializable(typeof(Pizza))] [JsonSerializable(typeof(List<PizzaSpecial>))] [JsonSerializable(typeof(List<Topping>))] [JsonSerializable(typeof(Topping))] [JsonSerializable(typeof(Dictionary<string, string>))] public partial class OrderContext : JsonSerializerContext { }