コード例 #1
0
        public async Task <JsonResult> TrackFor(TrackRequestDto dto)
        {
            Console.WriteLine($"Lat: {dto.Latitude} long: {dto.Longitude}");
            var user = await this.GetCurrentUser();

            dto.CreatedBy = user.Id;
            dto.IpAddress = retrieveIpAddress.GetRequestIp();

            var analyticsId = await createUserAnalyticsSessionCommand.Execute(dto);

            return(Json(new TrackResponseDto {
                AnalyticsId = analyticsId
            }));
        }
コード例 #2
0
        public async Task <LocationDto> Fetch(TrackRequestDto dto)
        {
            var location = retrievelocationFromIpAddress.Fetch(dto.IpAddress);

            if (dto.Latitude.HasValue && dto.Longitude.HasValue)
            {
                location.Latitude  = dto.Latitude;
                location.Longitude = dto.Longitude;

                var locationFromGPS = await retrieveLocationFromGpsData.Fetch(dto.Latitude.Value, dto.Longitude.Value);

                location.Country = locationFromGPS.Country;
                location.City    = locationFromGPS.City;
            }
            return(location);
        }
コード例 #3
0
        public async Task <long> CreateForEitherDocumentOrPresentation(TrackRequestDto dto)
        {
            await ConnectAndSetSchema();

            var id = await connection.QuerySingleAsync <long>(
                @"INSERT INTO user_analytics_sessions (presentation_id, document_id, created_by, ip_address, continent, country, city, latitude, longitude)
                VALUES (@PresentationId, @DocumentId, @CreatedBy, @IpAddress, @Continent, @Country, @City, @Latitude, @Longitude) RETURNING id;",
                new
            {
                dto.PresentationId,
                dto.DocumentId,
                dto.CreatedBy,
                dto.IpAddress,
                dto.Location.Continent,
                dto.Location.Country,
                dto.Location.City,
                dto.Location.Latitude,
                dto.Location.Longitude
            }
                );

            connection.Close();
            return(id);
        }
コード例 #4
0
        public async Task <long> Execute(TrackRequestDto dto)
        {
            dto.Location = await retrieveLocation.Fetch(dto);

            return(await userAnalyticsSessionRepository.CreateForEitherDocumentOrPresentation(dto));
        }