[#14] Models: Add DeliveryAncmt
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
using Elwig.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@ -39,6 +40,16 @@ namespace Elwig.Models.Entities {
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
[Column("ctime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long CTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime CreatedTimestamp => DateTimeOffset.FromUnixTimeSeconds(CTime).LocalDateTime;
|
||||
|
||||
[Column("mtime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long MTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime ModifiedTimestamp => DateTimeOffset.FromUnixTimeSeconds(MTime).LocalDateTime;
|
||||
|
||||
[ForeignKey("MgNr")]
|
||||
public virtual Member Member { get; private set; } = null!;
|
||||
|
||||
|
@ -83,15 +83,15 @@ namespace Elwig.Models.Entities {
|
||||
get => Utils.DecFromDb(AmountValue, 2);
|
||||
}
|
||||
|
||||
[Column("ctime")]
|
||||
[Column("ctime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long CTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime CreatedTimestamp => DateTimeOffset.FromUnixTimeSeconds(CTime).LocalDateTime;
|
||||
|
||||
[Column("mtime")]
|
||||
[Column("mtime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long MTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime ModifiedTimestamp => DateTimeOffset.FromUnixTimeSeconds(CTime).LocalDateTime;
|
||||
public DateTime ModifiedTimestamp => DateTimeOffset.FromUnixTimeSeconds(MTime).LocalDateTime;
|
||||
|
||||
[ForeignKey("Year, AvNr, MgNr")]
|
||||
public virtual PaymentMember Payment { get; private set; } = null!;
|
||||
|
@ -17,7 +17,6 @@ namespace Elwig.Models.Entities {
|
||||
|
||||
[Column("date")]
|
||||
public required string DateString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateOnly Date {
|
||||
get => DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
||||
@ -26,7 +25,6 @@ namespace Elwig.Models.Entities {
|
||||
|
||||
[Column("time")]
|
||||
public string? TimeString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public TimeOnly? Time {
|
||||
get => (TimeString == null) ? null : TimeOnly.ParseExact(TimeString, "HH:mm:ss");
|
||||
@ -63,6 +61,16 @@ namespace Elwig.Models.Entities {
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
[Column("ctime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long CTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime CreatedTimestamp => DateTimeOffset.FromUnixTimeSeconds(CTime).LocalDateTime;
|
||||
|
||||
[Column("mtime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long MTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime ModifiedTimestamp => DateTimeOffset.FromUnixTimeSeconds(MTime).LocalDateTime;
|
||||
|
||||
[ForeignKey("Year")]
|
||||
public virtual Season Season { get; private set; } = null!;
|
||||
|
||||
|
56
Elwig/Models/Entities/DeliveryAncmt.cs
Normal file
56
Elwig/Models/Entities/DeliveryAncmt.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using Elwig.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models.Entities {
|
||||
[Table("delivery_announcement"), PrimaryKey("Year", "DsNr", "MgNr", "SortId")]
|
||||
public class DeliveryAncmt {
|
||||
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[Column("dsnr")]
|
||||
public int DsNr { get; set; }
|
||||
|
||||
[Column("mgnr")]
|
||||
public int MgNr { get; set; }
|
||||
|
||||
[Column("sortid")]
|
||||
public required string SortId { get; set; }
|
||||
|
||||
[Column("weight")]
|
||||
public int Weight { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public required string Type { get; set; }
|
||||
|
||||
[Column("ctime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long CTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime CreatedTimestamp => DateTimeOffset.FromUnixTimeSeconds(CTime).LocalDateTime;
|
||||
|
||||
[Column("mtime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long MTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime ModifiedTimestamp => DateTimeOffset.FromUnixTimeSeconds(MTime).LocalDateTime;
|
||||
|
||||
[ForeignKey("Year, DsNr")]
|
||||
public virtual DeliverySchedule Schedule { get; private set; } = null!;
|
||||
|
||||
[ForeignKey("MgNr")]
|
||||
public virtual Member Member { get; private set; } = null!;
|
||||
|
||||
[ForeignKey("SortId")]
|
||||
public virtual WineVar Variety { get; private set; } = null!;
|
||||
|
||||
public int SearchScore(IEnumerable<string> keywords) {
|
||||
return Utils.GetSearchScore([
|
||||
Schedule.Description,
|
||||
Member.FamilyName, Member.MiddleName, Member.GivenName,
|
||||
Member.BillingAddress?.Name,
|
||||
], keywords);
|
||||
}
|
||||
}
|
||||
}
|
@ -128,6 +128,16 @@ namespace Elwig.Models.Entities {
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
|
||||
[Column("ctime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long CTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime CreatedTimestamp => DateTimeOffset.FromUnixTimeSeconds(CTime).LocalDateTime;
|
||||
|
||||
[Column("mtime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long MTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime ModifiedTimestamp => DateTimeOffset.FromUnixTimeSeconds(MTime).LocalDateTime;
|
||||
|
||||
[InverseProperty(nameof(DeliveryPartModifier.Part))]
|
||||
public virtual ICollection<DeliveryPartModifier> PartModifiers { get; private set; } = null!;
|
||||
|
||||
|
63
Elwig/Models/Entities/DeliverySchedule.cs
Normal file
63
Elwig/Models/Entities/DeliverySchedule.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using Elwig.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models.Entities {
|
||||
[Table("delivery_schedule"), PrimaryKey("Year", "DsNr")]
|
||||
public class DeliverySchedule {
|
||||
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[Column("dsnr")]
|
||||
public int DsNr { get; set; }
|
||||
|
||||
[Column("date")]
|
||||
public required string DateString { get; set; }
|
||||
[NotMapped]
|
||||
public DateOnly Date {
|
||||
get => DateOnly.ParseExact(DateString, "yyyy-MM-dd");
|
||||
set => DateString = value.ToString("yyyy-MM-dd");
|
||||
}
|
||||
|
||||
[Column("zwstid")]
|
||||
public required string ZwstId { get; set; }
|
||||
|
||||
[Column("description")]
|
||||
public required string Description { get; set; }
|
||||
|
||||
[Column("max_weight")]
|
||||
public int? MaxWeight { get; set; }
|
||||
|
||||
[Column("ancmt_from")]
|
||||
public long? AncmtFromUnix { get; set; }
|
||||
[NotMapped]
|
||||
public DateTime? AncmtFrom {
|
||||
get => AncmtFromUnix != null ? DateTimeOffset.FromUnixTimeSeconds(AncmtFromUnix.Value).LocalDateTime : null;
|
||||
set => AncmtFromUnix = value != null ? new DateTimeOffset(value.Value).ToUnixTimeSeconds() : null;
|
||||
}
|
||||
|
||||
[Column("ancmt_to")]
|
||||
public long? AncmtToUnix { get; set; }
|
||||
[NotMapped]
|
||||
public DateTime? AncmtTo {
|
||||
get => AncmtToUnix != null ? DateTimeOffset.FromUnixTimeSeconds(AncmtToUnix.Value).LocalDateTime : null;
|
||||
set => AncmtToUnix = value != null ? new DateTimeOffset(value.Value).ToUnixTimeSeconds() : null;
|
||||
}
|
||||
|
||||
[ForeignKey("Year")]
|
||||
public virtual Season Season { get; private set; } = null!;
|
||||
|
||||
[ForeignKey("ZwstId")]
|
||||
public virtual Branch Branch { get; private set; } = null!;
|
||||
|
||||
[InverseProperty(nameof(DeliveryScheduleWineVar.Schedule))]
|
||||
public virtual ICollection<DeliveryScheduleWineVar> Varieties { get; private set; } = null!;
|
||||
|
||||
public int SearchScore(IEnumerable<string> keywords) {
|
||||
return Utils.GetSearchScore([Description], keywords);
|
||||
}
|
||||
}
|
||||
}
|
26
Elwig/Models/Entities/DeliveryScheduleWineVar.cs
Normal file
26
Elwig/Models/Entities/DeliveryScheduleWineVar.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Elwig.Models.Entities {
|
||||
[Table("delivery_schedule_wine_variety"), PrimaryKey("Year", "DsNr", "SortId")]
|
||||
public class DeliveryScheduleWineVar {
|
||||
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[Column("dsnr")]
|
||||
public int DsNr { get; set; }
|
||||
|
||||
[Column("sortid")]
|
||||
public required string SortId { get; set; }
|
||||
|
||||
[Column("priority")]
|
||||
public int Priority { get; set; }
|
||||
|
||||
[ForeignKey("Year, DsNr")]
|
||||
public virtual DeliverySchedule Schedule { get; private set; } = null!;
|
||||
|
||||
[ForeignKey("SortId")]
|
||||
public virtual WineVar Variety { get; private set; } = null!;
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ namespace Elwig.Models.Entities {
|
||||
|
||||
[Column("middle_names")]
|
||||
public string? MiddleName { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public string[] MiddleNames {
|
||||
get => (MiddleName != null) ? MiddleName.Split(" ") : [];
|
||||
@ -59,7 +58,6 @@ namespace Elwig.Models.Entities {
|
||||
|
||||
[Column("entry_date")]
|
||||
public string? EntryDateString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateOnly? EntryDate {
|
||||
get => EntryDateString != null ? DateOnly.ParseExact(EntryDateString, "yyyy-MM-dd") : null;
|
||||
@ -68,7 +66,6 @@ namespace Elwig.Models.Entities {
|
||||
|
||||
[Column("exit_date")]
|
||||
public string? ExitDateString { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateOnly? ExitDate {
|
||||
get => ExitDateString != null ? DateOnly.ParseExact(ExitDateString, "yyyy-MM-dd") : null;
|
||||
@ -146,10 +143,19 @@ namespace Elwig.Models.Entities {
|
||||
|
||||
[ForeignKey("DefaultKgNr")]
|
||||
public virtual WbKg? DefaultWbKg { get; private set; }
|
||||
|
||||
[NotMapped]
|
||||
public AT_Kg? DefaultKg => DefaultWbKg?.AtKg;
|
||||
|
||||
[Column("ctime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long CTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime CreatedTimestamp => DateTimeOffset.FromUnixTimeSeconds(CTime).LocalDateTime;
|
||||
|
||||
[Column("mtime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long MTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime ModifiedTimestamp => DateTimeOffset.FromUnixTimeSeconds(MTime).LocalDateTime;
|
||||
|
||||
[ForeignKey("ZwstId")]
|
||||
public virtual Branch? Branch { get; private set; }
|
||||
|
||||
|
@ -35,9 +35,9 @@ namespace Elwig.Models.Entities {
|
||||
public bool TestVariant { get; set; }
|
||||
|
||||
[Column("calc_time")]
|
||||
public int? CalcTimeUnix { get; set; }
|
||||
public long? CalcTimeUnix { get; set; }
|
||||
[NotMapped]
|
||||
public DateTime? CalcTime => CalcTimeUnix != null ? DateTimeOffset.FromUnixTimeSeconds((long)CalcTimeUnix).UtcDateTime.ToLocalTime() : null;
|
||||
public DateTime? CalcTime => CalcTimeUnix != null ? DateTimeOffset.FromUnixTimeSeconds(CalcTimeUnix.Value).LocalDateTime : null;
|
||||
|
||||
[Column("comment")]
|
||||
public string? Comment { get; set; }
|
||||
@ -45,6 +45,16 @@ namespace Elwig.Models.Entities {
|
||||
[Column("data")]
|
||||
public required string Data { get; set; }
|
||||
|
||||
[Column("ctime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long CTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime CreatedTimestamp => DateTimeOffset.FromUnixTimeSeconds(CTime).LocalDateTime;
|
||||
|
||||
[Column("mtime"), DatabaseGenerated(DatabaseGeneratedOption.Computed)]
|
||||
public long MTime { get; private set; }
|
||||
[NotMapped]
|
||||
public DateTime ModifiedTimestamp => DateTimeOffset.FromUnixTimeSeconds(MTime).LocalDateTime;
|
||||
|
||||
[ForeignKey("Year")]
|
||||
public virtual Season Season { get; private set; } = null!;
|
||||
|
||||
|
Reference in New Issue
Block a user