Repeated Code
I can see the repeated code, which can be removed by introducing following method:
public static void AddToSoonestDrawDateModel(SomeTypestring itemday, int dayId, int cutOffDayId)
{
var sdModel = new SoonestDrawDateModel
{
DrawDay = itemday,
DrawDayId = item.DayIddayId,
CutOffDayId = item.CutOffDayIdcutOffDayId
};
soonestDrawDateModel.Add(sdModel);
}
After refactoring code should be like this:
var soonestDrawDateModel = new List<SoonestDrawDateModel>();
foreach (var item in drawDates)
{
AddToSoonestDrawDateModel(item);
item.DayId =Day, item.DayId + 7
, AddToSoonestDrawDateModel(item.CutOffDayId);
}
var realDrawDates = soonestDrawDateModel.OrderBy(x => x.DrawDayId);
Obviously, it is not LINQ, but it is more neat, readable and less repetitive code.