代码之家  ›  专栏  ›  技术社区  ›  hanan

在使用Rest API时,避免使用Put/Patch对每个更新进行验证检查

  •  0
  • hanan  · 技术社区  · 6 年前

    Rest-API 在里面 Asp.net core 面对一个乏味的问题。 每次我都要验证我的数据 put/patch

    数据会随时更新 SupplyOrderState 会改变的。

    1. 所有关系ID都有效
    2. 一旦订单被批准,您就不能编辑
    3. 检查订购的产品是否有效

    ,

    public class SupplyOrder : BaseEntity
    {
        public long SupplierId { get; set; }
        public Supplier Supplier { get; set; }
    
        public DateTime CreationDate { get; set; }
        public DateTime? DeliveredDate { get; set; }
        public DateTime? CancellationDate { get; set; }
    
        public long CostCenterId { get; set; }
        public CostCenter CostCenter { get; set; }
    
        public SupplyOrderStates SupplyOrderStates { get; set; }
    
        public string ApproverUserId { get; set; }
        public ApplicationUser ApproverUser { get; set; }
    
        public string CancellerUserId { get; set; }
        public ApplicationUser CancellerUser { get; set; }
    
        public string ReceiverUserId { get; set; }
        public ApplicationUser ReceiverUser { get; set; }
    
        public ICollection<SupplyOrderDetail> SupplyOrderDetails { get; set; }
        public ICollection<SupplyTransportationDocument> SupplyTransportationDocuments { get; set; }
    }
    
    
     public enum SupplyOrderStates
    {
        preApproved = 0,
        approved = 1,
        notApproved = 2,
        delivered = 3,
        partialDelivered = 4,
        cancled = 5
    }
    
    0 回复  |  直到 6 年前