You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
646 B
21 lines
646 B
|
4 days ago
|
namespace Housing.Models;
|
||
|
|
|
||
|
|
public static class ResistanceStorage
|
||
|
|
{
|
||
|
|
public const decimal Minimum = -999.99m;
|
||
|
|
public const decimal Maximum = 999.99m;
|
||
|
|
|
||
|
|
public static bool ExceedsRange(decimal? resistanceKilohms)
|
||
|
|
{
|
||
|
|
if (!resistanceKilohms.HasValue) return false;
|
||
|
|
return resistanceKilohms.Value < Minimum || resistanceKilohms.Value > Maximum;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static decimal? ToDatabaseValue(decimal? resistanceKilohms)
|
||
|
|
{
|
||
|
|
return !resistanceKilohms.HasValue || ExceedsRange(resistanceKilohms)
|
||
|
|
? null
|
||
|
|
: decimal.Round(resistanceKilohms.Value, 2, MidpointRounding.AwayFromZero);
|
||
|
|
}
|
||
|
|
}
|