using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Util.Domain;
using Util.Domain.Entities;
namespace Util.Tests.Models;
///
/// 订单
///
[Description( "订单" )]
public class Order : AggregateRoot, IDelete {
///
/// 初始化订单
///
public Order() : this( string.Empty ) {
}
///
/// 初始化订单
///
/// 订单标识
public Order( string id ) : base( id ) {
OrderItems = new List();
}
///
/// 客户标识
///
[Description( "客户标识" )]
public int? CustomerId { get; set; }
///
/// 客户名称
///
[Description( "客户名称" )]
[MaxLength( 200 )]
public string CustomerName { get; set; }
///
/// 金额
///
[Description( "金额" )]
[Required( ErrorMessage = "金额不能为空" )]
public decimal Amount { get; set; }
///
/// 下单时间
///
[Description( "下单时间" )]
public DateTime? PlaceOrderTime { get; set; }
///
/// 订单状态
///
[Description( "订单状态" )]
[Required( ErrorMessage = "订单状态不能为空" )]
public int State { get; set; }
///
/// 是否删除
///
[Description( "是否删除" )]
public bool IsDeleted { get; set; }
///
/// 订单项列表
///
public ICollection OrderItems { get; set; }
///
/// 添加变更列表
///
protected override void AddChanges( Order other ) {
AddChange( t => t.CustomerId, other.CustomerId );
AddChange( t => t.CustomerName, other.CustomerName );
AddChange( t => t.Amount, other.Amount );
AddChange( t => t.PlaceOrderTime, other.PlaceOrderTime );
AddChange( t => t.State, other.State );
}
}