Add DeliveryAdminWindow

This commit is contained in:
2023-05-22 21:32:06 +02:00
parent 3bf7d65dea
commit dc236bab62
13 changed files with 534 additions and 35 deletions

View File

@ -1,6 +1,8 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
namespace Elwig.Models {
[Table("wine_origin"), PrimaryKey("HkId"), Index("Name", IsUnique = true)]
@ -22,5 +24,21 @@ namespace Elwig.Models {
[InverseProperty("Origin")]
public virtual ISet<WbGem> Gems { get; private set; }
[InverseProperty("Parent")]
public virtual ISet<WineOrigin> Children { get; private set; }
public int Level => (Parent?.Level + 1) ?? 0;
public string HkIdLevel => $"{new string(' ', Level * 2)}{HkId}";
public int TotalChildNum => 1 + Children.Select(c => c.TotalChildNum).Sum();
private int SortKey1 => (Parent?.SortKey1 ?? 0) | (TotalChildNum << ((3 - Level) * 8));
public int SortKey => SortKey1 | ((Level < 3) ? (-1 >>> (Level * 8 + 8)) : 0);
public override string ToString() {
return Name;
}
}
}