Models: Add Entities/ folder
This commit is contained in:
58
Elwig/Models/Entities/Modifier.cs
Normal file
58
Elwig/Models/Entities/Modifier.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using Elwig.Helpers;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
|
||||
namespace Elwig.Models.Entities {
|
||||
[Table("modifier"), PrimaryKey("Year", "ModId")]
|
||||
public class Modifier {
|
||||
[Column("year")]
|
||||
public int Year { get; set; }
|
||||
|
||||
[Column("modid")]
|
||||
public string ModId { get; set; }
|
||||
|
||||
[Column("ordering")]
|
||||
public int Ordering { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("abs")]
|
||||
public long? AbsValue { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public decimal? Abs {
|
||||
get => AbsValue != null ? Season.DecFromDb(AbsValue.Value) : null;
|
||||
set => AbsValue = value != null ? Season.DecToDb(value.Value) : null;
|
||||
}
|
||||
|
||||
[Column("rel")]
|
||||
public double? RelValue { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public decimal? Rel {
|
||||
get => (decimal?)RelValue;
|
||||
set => RelValue = (double?)value;
|
||||
}
|
||||
|
||||
[Column("standard")]
|
||||
public bool IsStandard { get; set; }
|
||||
|
||||
[Column("quick_select")]
|
||||
public bool IsQuickSelect { get; set; }
|
||||
|
||||
[ForeignKey("Year")]
|
||||
public virtual Season Season { get; private set; }
|
||||
|
||||
public string ValueStr =>
|
||||
(Abs != null) ? $"{Utils.GetSign(Abs.Value)}{Math.Abs(Abs.Value).ToString("0." + string.Concat(Enumerable.Repeat('0', Season.Precision)))}\u00a0{Season.Currency.Symbol}/kg" :
|
||||
(Rel != null) ? $"{Utils.GetSign(Rel.Value)}{(Math.Abs(Rel.Value) < 0.1m ? "\u2007" : "")}{Math.Abs(Rel.Value):0.00##\u00a0%}" :
|
||||
"";
|
||||
|
||||
public override string ToString() {
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user