public static IEnumerable <ReadRideDTO> GetRidesOfCard(string cardId) { try { var query = DataLayer.Client.Cypher .Match("(c:Card) - [: OF_RIDE] -> (ride:Ride)", "(ride: Ride)-[: ARRIVES ]->(arrive : Station)", "(ride: Ride)<-[: TAKES_OF ]- (takeOf : Station)", "(ride:Ride) - [: CARRIER] -> (carrier: Carrier)") .Where((Card c) => c.Id == cardId) .Return((ride, arrive, takeOf, carrier) => new BusinessRide() { Ride = ride.As <Ride>(), Carrier = carrier.As <Carrier>(), ArrivalStation = arrive.As <Station>(), TakeOfStation = takeOf.As <Station>() }).Results; return(ReadRideDTO.FromEntityList(query)); } catch (Exception e) { return(new List <ReadRideDTO>()); } }
public static IEnumerable <ReadRideDTO> GetRidesByCarrier(string carrierId) { try { var query = DataLayer.Client.Cypher .Match("(ride: Ride)-[: ARRIVES ]->(arrive : Station)", "(ride: Ride)<-[: TAKES_OF ]- (takeOf : Station)", "(ride:Ride) - [: CARRIER] -> (carrier: Carrier)") .Where((Carrier carrier) => carrier.Id == carrierId) .Return((ride, arrive, takeOf, carrier) => new BusinessRide() { Ride = ride.As <Ride>(), Carrier = carrier.As <Carrier>(), ArrivalStation = arrive.As <Station>(), TakeOfStation = takeOf.As <Station>() }).Results; //if (query != null && query.Count() > 0) //{ // var ride = query.ToList(); // return ReadRideDTO.FromEntityList(ride); //} //return null; return(ReadRideDTO.FromEntityList(query)); } catch (Exception e) { return(new List <ReadRideDTO>()); } }