public DateTime GetMaxEndTime(ITimeRepository timeRepository, DataRow dataRow) { DateTime time = new DateTime(); foreach (DataRow row in timeRepository.GetMaxEndTimeFromInLine(dataRow).Rows) { if (row["time"].ToString() == "") { time = timeRepository.GetMaxEndTimeFromItemsOperationsDisplay(dataRow); } else { time = Convert.ToDateTime(row["time"]); } } return(time); }