98 lines
2.8 KiB
C#
98 lines
2.8 KiB
C#
using Elwig.Helpers;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Linq;
|
|
|
|
namespace Elwig.Models {
|
|
[Table("season"), PrimaryKey("Year")]
|
|
public class Season {
|
|
[Column("year")]
|
|
public int Year { get; set; }
|
|
|
|
[Column("currency")]
|
|
public string CurrencyCode { get; set; }
|
|
|
|
[Column("precision")]
|
|
public byte Precision { get; set; }
|
|
|
|
[Column("start_date")]
|
|
public string? StartDateString { get; set; }
|
|
|
|
[NotMapped]
|
|
public DateOnly? StartDate {
|
|
get {
|
|
return StartDateString != null ? DateOnly.ParseExact(StartDateString, "yyyy-MM-dd") : null;
|
|
}
|
|
set {
|
|
StartDateString = value?.ToString("yyyy-MM-dd");
|
|
}
|
|
}
|
|
|
|
[Column("end_date")]
|
|
public string? EndDateString { get; set; }
|
|
|
|
[NotMapped]
|
|
public DateOnly? EndDate {
|
|
get {
|
|
return EndDateString != null ? DateOnly.ParseExact(EndDateString, "yyyy-MM-dd") : null;
|
|
}
|
|
set {
|
|
EndDateString = value?.ToString("yyyy-MM-dd");
|
|
}
|
|
}
|
|
|
|
[Column("bin_1_name")]
|
|
public string? Bin1Name { get; set; }
|
|
|
|
[Column("bin_2_name")]
|
|
public string? Bin2Name { get; set; }
|
|
|
|
[Column("bin_3_name")]
|
|
public string? Bin3Name { get; set; }
|
|
|
|
[Column("bin_4_name")]
|
|
public string? Bin4Name { get; set; }
|
|
|
|
[Column("bin_5_name")]
|
|
public string? Bin5Name { get; set; }
|
|
|
|
[Column("bin_6_name")]
|
|
public string? Bin6Name { get; set; }
|
|
|
|
[Column("bin_7_name")]
|
|
public string? Bin7Name { get; set; }
|
|
|
|
[Column("bin_8_name")]
|
|
public string? Bin8Name { get; set; }
|
|
|
|
[Column("bin_9_name")]
|
|
public string? Bin9Name { get; set; }
|
|
|
|
[NotMapped]
|
|
public string[] BinNames => (new string?[] { Bin1Name, Bin2Name, Bin3Name, Bin4Name, Bin5Name, Bin6Name, Bin7Name, Bin8Name, Bin9Name })
|
|
.Where(n => n != null).Select(n => n ?? "").ToArray();
|
|
|
|
[ForeignKey("CurrencyCode")]
|
|
public virtual Currency Currency { get; private set; }
|
|
|
|
[InverseProperty("Season")]
|
|
public virtual ISet<Modifier> Modifiers { get; private set; }
|
|
|
|
[InverseProperty("Season")]
|
|
public virtual ISet<PaymentVar> PaymentVariants { get; private set; }
|
|
|
|
[InverseProperty("Season")]
|
|
public virtual ISet<Delivery> Deliveries { get; private set; }
|
|
|
|
public decimal DecFromDb(long value) {
|
|
return Utils.DecFromDb(value, Precision);
|
|
}
|
|
|
|
public long DecToDb(decimal value) {
|
|
return Utils.DecToDb(value, Precision);
|
|
}
|
|
}
|
|
}
|