I'm building an application for a bonded-warehouse. They have services calculated by Unit price like "Container surveillance duty = containers number x storage days x unit price" and they have Container storage duty that its price is variant according to time intervals like :
1 to 3 days price1
4 to 10 days price2
up to 11 days price3
I wanted to apply sort of OCP and keep price calculation methods implementation open and easy as I'm using Entity Framework code first.(I know that sounds a bit crazy)
I built this model using inheritance but I'm actually not self convinced with the result, so I did post it to check whether it's correct. My aim is to have a pricing scale that contains all the services with different calculation methods.
So my question is : Is this model correct ?
Here is the model :
public class Service
{
public int ServiceId { get; set; }
public string Name { get; set; }
}
public class Pricing
{
public int PricingId { get; set; }
public int ServiceId { get; set; }
}
public class UnitaryPricing : Pricing
{
public decimal UnitPrice { get; set; }
}
public class StoragePricing : Pricing
{
public List<TimeIntervalPricing> TimeIntervalPricings { get; set; }
}
public class TimeIntervalPricing
{
public int TimeIntervalPricingId { get; set; }
public int IntervalStart { get; set; }
public int IntervalEnd { get; set; }
public decimal Price { get; set; }
}
