private DO.Station StationFromBoToDo(BO.Station station) { DO.Station DoStation = (DO.Station)station.CopyPropertiesToNew(typeof(DO.Station)); DoStation.Latitude = station.Location.Latitude; DoStation.Longitude = station.Location.Longitude; return(DoStation); }
private BO.Station StationFromDoToBoAdjacents(DO.Station station1) { BO.Station result = StationFromDoToBo(station1); IEnumerable <DO.AdjacentStations> DoAdjacents = dl.GetAllAdjacentStationsBy(ad => ad.StationCode1 == station1.Code || ad.StationCode2 == station1.Code); result.AdjacentStations = from item in DoAdjacents select AdjFromDoToBo(item, item.StationCode1 == station1.Code?item.StationCode2 : item.StationCode1); //דואגים שתמיד התחנה שלנו תיהיה ראשונה בעוקבות ;//המרה של כל תחנה עוקבת return(result); }
public BO.Station GetStationWithAdjacents(int stationKey) { try { DO.Station DoStation = dl.GetStation(stationKey); return(StationFromDoToBoAdjacents(DoStation)); } catch (DO.BadStationKeyException e) { throw new BO.BadStationKeyException(stationKey, e.Message); } }
/// <summary> /// Add new station to the database /// </summary> /// <param name="station"></param> public void AddStation(DO.Station station) { var st = DS.DataSource.StationsList.FirstOrDefault(s => s.Code == station.Code); if (st != null && !st.IsDeleted) { throw new DO.BadStationException(station.Code, "Duplicate Station"); } else { DS.DataSource.StationsList.Add(station.Clone()); } }
public void AddStation(DO.Station station) { var stationList = XmlTools.LoadListFromXMLSerializer <DO.Station>(stationPath); var st = stationList.Find(s => s.Code == station.Code); if (st != null && !station.IsDeleted) { throw new DO.BadStationException(station.Code, "Duplicate Station"); } stationList.Add(station); XmlTools.SaveListToXMLSerializer(stationList, stationPath); }
/// <summary> /// Update station /// </summary> /// <param name="station"></param> public void UpdateStation(DO.Station station) { var stationToUp = DS.DataSource.StationsList.Find(s => s.Code == station.Code); if (stationToUp != null && !stationToUp.IsDeleted) { DS.DataSource.StationsList.Remove(stationToUp); DS.DataSource.StationsList.Add(station); } else { throw new DO.BadStationException(station.Code, "Station not found"); } }
public void UpdateStation(DO.Station station) { var stationList = XmlTools.LoadListFromXMLSerializer <DO.Station>(stationPath); var stationToUp = stationList.Find(s => s.Code == station.Code); if (stationToUp != null && !stationToUp.IsDeleted) { stationList.Remove(stationToUp); stationList.Add(station); XmlTools.SaveListToXMLSerializer(stationList, stationPath); } else { throw new DO.BadStationException(station.Code, "Station not found"); } }
public void UpdateStation(BO.Station s) { //from BO to DO DO.Station DOstation = StationFromBoToDo(s); try { dl.UpdateStation(DOstation); foreach (var item in s.AdjacentStations) { dl.AddAdjacentStations(AdjFromBoToDo(item, s.Code)); } } catch (DO.BadStationKeyException e) { throw new BO.BadStationKeyException(s.Code, e.Message); } }
public void RemoveStation(DO.Station station) { var stationList = XmlTools.LoadListFromXMLSerializer <DO.Station>(stationPath); var stationToRem = stationList.Find(s => s.Code == station.Code); if (stationToRem != null && !stationToRem.IsDeleted) { GetAllLineStationBy(s => s.Station == stationToRem.Code).ToList().ForEach(RemoveLineStation); GetAllAdjacentStationsBy(s => s.Station1 == stationToRem.Code || s.Station2 == stationToRem.Code).ToList().ForEach(RemoveAdjacentStations); stationList.Remove(stationToRem); stationToRem.IsDeleted = true; stationList.Add(stationToRem); XmlTools.SaveListToXMLSerializer(stationList, stationPath); } else { throw new DO.BadStationException(station.Code, "Station not found"); } }
/// <summary> /// Remove station from the database /// </summary> /// <param name="station"></param> public void RemoveStation(DO.Station station) { var stationToRem = DS.DataSource.StationsList.Find(s => s.Code == station.Code); if (stationToRem != null && !stationToRem.IsDeleted) { // remove all the line station of this station GetAllLineStationBy(s => s.Station == stationToRem.Code).ToList().ForEach(RemoveLineStation); // remove all all adjacent stations pf this station GetAllAdjacentStationsBy(s => s.Station1 == stationToRem.Code || s.Station2 == stationToRem.Code).ToList().ForEach(RemoveAdjacentStations); DS.DataSource.StationsList.Remove(stationToRem); stationToRem.IsDeleted = true; DS.DataSource.StationsList.Add(stationToRem); } else { throw new DO.BadStationException(station.Code, "Station not found"); } }
private BO.Station StationFromDoToBo(DO.Station station) { BO.Station BoStation = (BO.Station)station.CopyPropertiesToNew(typeof(BO.Station)); BoStation.Location = new BO.Location(station.Latitude, station.Longitude); return(BoStation); }