/// <summary> /// request a bus Travel according to a predicate /// </summary> /// <param name="pr"></param> /// <returns>the wanted bus travel</returns> public BusTravel RequestBusTravel(Predicate <BusTravel> pr = null) { BusTravel ret = DataSource.BusTravelList.Find(busTravel => pr(busTravel)); if (ret == null) { throw new Exception("no busTravel that meets these conditions!"); } if (ret.Valid == false) { throw new Exception("busTravel that meets these conditions is not valid"); } return(ret.GetPropertiesFrom <BusTravel, BusTravel>()); }
public void CreateBusTravel(long licenseNumber, long lineId, DateTime formalDepartureTime, DateTime realDepartureTime, long lastPassedStop, DateTime lastPassedStopTime, DateTime nextStopTime, string driverId) { string exception = ""; bool foundException = false; try { valid.ExistLicense(licenseNumber); } catch (Exception ex) { exception += ex.Message; foundException = true; } try { valid.TimeAfter(formalDepartureTime, realDepartureTime, "formalDepartureTime", "realDepartureTime"); } catch (Exception ex) { exception += ex.Message; foundException = true; } try { valid.TimeAfter(lastPassedStopTime, nextStopTime, "formalDepartureTime", "realDepartureTime"); } catch (Exception ex) { exception += ex.Message; foundException = true; } try { valid.GoodInt(lastPassedStop); } catch (Exception ex) { exception += ex.Message; foundException = true; } //try //{ // valid.UserNameExist(lastPassedStop); //} //catch (Exception ex) //{ // exception += ex.Message; // foundException = true; //} try { valid.LineIdExist(lineId); } catch (Exception ex) { exception += ex.Message; foundException = true; } //if (foundException) // throw new Exception(exception); BusTravel busTravelBO = new BusTravel(licenseNumber, lineId, formalDepartureTime, realDepartureTime, lastPassedStop, lastPassedStopTime, nextStopTime, driverId); DO.BusTravel busTravelDO = busTravelBO.GetPropertiesFrom <DO.BusTravel, BO.BusTravel>(); dal.CreateBusTravel(busTravelDO); }