public static CurrentDayRoute GetOneCDR(int? cdrkey) { // original return (CurrentDayRoute.All().Where(x => (x.CurrentDayRouteID == cdrkey))).FirstOrDefault(); var name = "GetOneCDR(int? cdrkey)"; if (cdrkey.HasValue) { return (CurrentDayRoute.Find(x => x.CurrentDayRouteID == cdrkey).First()); } else { CurrentDayRoute cdr = CurrentDayRoute.Find(x => x.CurrentDayRouteID == cdrkey.Value).DefaultIfEmpty( new CurrentDayRoute { CDRRouteID = "xx", CDRRouteName = name, DUser = "******", Terminal = "not allowed" }).First(); return cdr; } }
public static CurrentDayRoute GetRouteWithKey(int? key) { var first = CurrentDayRoute.Find(x => x.CurrentDayRouteID == key).FirstOrDefault() ?? new CurrentDayRoute { CurrentDayRouteID = 500, CDRDriverLastName = "invalid route" }; return first; }