コード例 #1
0
        public async Task <dynamic> GetUserTransportations(Guid userId, DateTime periodStart, DateTime periodEnd)
        {
            var userTransportationRelationship             = new UserTransportationRelationship("user", "transportation");
            var transportationCapturedLocationRelationship =
                new TransportationCapturedLocationRelationship("transportation", "capturedLocation");

            var query = new CypherFluentQuery(_graphClientFunc)
                        .Match("(user:User{azureId: {userId}})")
                        .WithParam("userId", userId)
                        .MatchRelationship(userTransportationRelationship)
                        .Match("(transportation:Transportation)")
                        .MatchRelationship(transportationCapturedLocationRelationship)
                        .Where("capturedLocation.capturedDateTimeUtc >= {periodStart} " +
                               "AND capturedLocation.capturedDateTimeUtc <= {periodEnd}")
                        .WithParam("periodStart",
                                   periodStart.ToUniversalTime().Subtract(DateTime.MinValue.AddYears(1969)).TotalSeconds)
                        .WithParam("periodEnd",
                                   periodEnd.ToUniversalTime().Subtract(DateTime.MinValue.AddYears(1969)).TotalSeconds)
                        .Return((transportation, capturedLocation) => new
            {
                transportation    = transportation.As <Transportation>(),
                capturedLocations = capturedLocation.CollectAs <CapturedLocation>()
            });
            var result = await _repositoryPolicy.ExecuteAsync(async() => await query.ResultsAsync);

            return(result);
        }
コード例 #2
0
        public async Task SaveTransportation(Transportation transportation, Guid userId)
        {
            var relationship = new UserTransportationRelationship("user", "transportation");

            var query = new CypherFluentQuery(_graphClientFunc)
                        .CreateEntity(transportation, "transportation")
                        .With("transportation")
                        .Match("(user:User{azureId: {userId}})")
                        .WithParam("userId", userId)
                        .CreateRelationship(relationship);
            await query.ExecuteWithoutResultsAsync();
        }
コード例 #3
0
        public async Task <GetTransportationDetailsResultMessage> GetTransportationDetails(Guid transportationId)
        {
            var userTransportationRelationship = new UserTransportationRelationship("user", "transportation");

            var query = new CypherFluentQuery(_graphClientFunc)
                        .Match("(transportation:Transportation{transportationId: {transportationId}})")
                        .WithParam("transportationId", transportationId)
                        .MatchRelationship(userTransportationRelationship)
                        .Match("(transportation:Transportation)")
                        .OptionalMatch("(transportation:Transportation)-[:HAS_ALERT]->(alert:Alert)")
                        .OptionalMatch("(user:User)-[:HAS_VIOLATION]->(violation:Violation)")
                        .Return((user, violation, alert) => new GetTransportationDetailsResultMessage
            {
                User       = user.As <UserDto>(),
                Violations = violation.CollectAs <ViolationDto>(),
                Alerts     = alert.CollectAs <AlertResultDto>()
            });
            var result = await _repositoryPolicy.ExecuteAsync(async() => await query.ResultsAsync);

            return(result.FirstOrDefault());
        }