I have an observable collection of Bids, class structure below.
public class Bids
{
public DateTime StartDateTimeLocal { get; set; }
public DateTime EndDateTimeLocal { get; set; }
public decimal Bid5 { get; set; }
public decimal Price5 { get; set; }
public decimal Bid4 { get; set; }
public decimal Price4 { get; set; }
public decimal Bid3 { get; set; }
public decimal Price3 { get; set; }
public decimal Bid2 { get; set; }
public decimal Price2 { get; set; }
public decimal Bid1 { get; set; }
public decimal Price1 { get; set; }
}
I have an observable collection
public ObservableCollection<Bid> Bids {get; set;}
Bids collection looks like below,
StartDateTimeLocal EndDateTimeLocal Bid5 Price5 Bid4 Price4 Bid3 Price3 Bid2 Price2 Bid1 Price1 2014-02-14 23:00 2014-02-14 23:30 0 0 0 0 0 0 50 10 100 100 2014-02-14 23:30 2014-02-15 00:00 0 0 0 0 0 0 10 300 200 10 2014-02-15 00:00 2014-02-15 00:30 0 0 0 0 0 0 100 30 0 10 2014-02-15 03:00 2014-02-15 01:00 0 0 0 0 0 0 30 100 0 0
I need to validate the data in the observable collection is valid as per the rules...
- Bid 2 should only have a value if bid 1 has a value. So, unless there is a bid 1 a non zero value in bid 2 is invalid. Similarly a a value in bid1, bid2, bid3 is fine but if bid4 doesn't have a value then a value in bid5 is invalid.
- Bid prices must be constant or increasing as you go up bids. So, bid 2 price should either be same or greater than bid 1 price.
In the above sample,
- The 3rd & 4th row are incorrect since Bid1 doesn't have a value but
Bid2 does.
- The 2nd row is correct since Bid1 has a value and hence Bid2
having a value is fine, The price of Bid2 > Bid1. While Row 1 is
incorrect since Price of Bid 2 is < Price of Bid 1
Can some one please advise an approach to perform this validation.