// ++ /// <summary> /// request a LineDeparture according to a predicate /// </summary> /// <param name="pr"></param> /// <returns></returns> public LineDeparture RequestLineDeparture(Predicate<LineDeparture> pr = null) { LineDeparture ret = DataSource.LineDepartureList.Find(lineDeparture => pr(lineDeparture)); if (ret == null) throw new Exception("no lineDeparture that meets these conditions!"); if (ret.Valid == false) throw new Exception("lineDeparture that meets these conditions is not valid"); return ret.GetPropertiesFrom<LineDeparture, LineDeparture>(); }
public void CreateLineDeparture(long id, DateTime timeStart, int frequency, DateTime timeEnd) { string exception = ""; bool foundException = false; try { valid.GoodLong(id); } catch (Exception ex) { exception += ex.Message; foundException = true; } try { valid.GoodLong(frequency); } catch (Exception ex) { exception += ex.Message; foundException = true; } try { valid.GoodDate(timeStart, timeEnd); } catch (Exception ex) { exception += ex.Message; foundException = true; } if (foundException) { throw new Exception(exception); } LineDeparture lineDepartureBO = new LineDeparture(timeStart, timeEnd, frequency, id); DO.LineDeparture lineDepartureDO = lineDepartureBO.GetPropertiesFrom <DO.LineDeparture, BO.LineDeparture>(); dal.CreateLineDeparture(lineDepartureDO); }