public bool CreateStation(Station station)
 {
     try
     {
         _stationRepository.Insert(station);
         return true;
     }
     catch (Exception ex)
     {
         HandleLogging.LogMessage(ex, "CreateStation", 1, WebOperationContext.Current);
         return false;
     }
 }
        public void Update(Station station)
        {
            Station rStation = GetStationById(station.ID);

            if (rStation == null)
                return;

            rStation.Title = station.Title;
            rStation.Description = station.Description;
            rStation.StationLat = station.StationLat;
            rStation.StationLong = station.StationLong;
            rStation.IsActive = station.IsActive;
            rStation.IsOperational = station.IsOperational;
            db.SaveChanges();
        }
        public List<Edge> GetEdgesByStartStation(Station station)
        {
            var edges = db.Edges.Where(x => x.StartStationId.Equals(station.ID));
            var returnList = new List<Edge>();
            foreach (var edge in edges)
            {
                edge.EndStation = db.Stations.AsNoTracking().FirstOrDefault(x => x.ID.Equals(edge.EndStationId));
                if (edge.EndStation != null)
                {
                    var batteryStorage =
                        db.BatteryStorages.AsNoTracking().FirstOrDefault(
                            x => x.StationId.Equals(edge.EndStationId) && x.IsActive);
                    if(batteryStorage != null)
                        if((batteryStorage.Available - batteryStorage.Reserved - batteryStorage.Charging) > 0)
                            returnList.Add(edge);
                }
            }

            return returnList;
        }
 public void Insert(Station station)
 {
     db.Stations.Add(station);
     db.SaveChanges();
 }
예제 #5
0
 private void ReconstructPath(Station current)
 {
     Station temp;
     if (_cameFrom.TryGetValue(current, out temp))
     {
         Edge e = _edgeRepository.GetEdgeByStartEndStation(temp, current);
         current.Edges = new List<Edge> { e };
         ReconstructPath(temp);
         _path.Add(current);
     }
     else
     {
         current.Edges = new List<Edge>();
         _path.Add(current);
     }
 }
예제 #6
0
 private void InsertVertex(Station vert, List<Station> path, decimal fScore)
 {
     vert.Edges = _edgeRepository.GetEdgesByStartStation(vert);
     _openSet.Insert(vert, path, fScore);
 }
예제 #7
0
 private decimal Heuristic(Station start, Station end)
 {
     var endEdge = _edgeRepository.GetEdgeByStartEndStation(start, end);
     return endEdge != null ? endEdge.Distance : -1;
 }
 protected bool Equals(Station other)
 {
     return ID == other.ID;
 }
 public bool CreateStation(Station station)
 {
     return new StationService().CreateStation(station);
 }
 public bool UpdateStation(Station station)
 {
     return new StationService().UpdateStation(station);
 }
 public Edge GetEdgeByStartEndStation(Station start, Station end)
 {
     return db.Edges.AsNoTracking().FirstOrDefault(x => x.StartStationId.Equals(start.ID) && x.EndStationId.Equals(end.ID));
 }
        public IQueryable<Edge> GetEdgesByStation(Station station)
        {
            var edges = db.Edges.Where(x => x.StartStationId.Equals(station.ID) || x.EndStationId.Equals(station.ID));
            foreach (var edge in edges)
            {
                edge.EndStation = db.Stations.FirstOrDefault(x => x.ID.Equals(edge.EndStationId));
            }

            return edges;
        }