[#14] Models: Add DeliveryAncmt
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user