This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ClientLocation | |
| { | |
| public Guid Id { get; set; } | |
| public Guid ClientId { get; set; } | |
| public GeoJsonPoint<GeoJson2DGeographicCoordinates> Coordinates { get; set; } | |
| public DateTime CurrentTimeStamp { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<LocationResponse> RetrieveLocations(Guid clientId, DateTime? startDate = null, | |
| DateTime? endDate = null) | |
| { | |
| var list = new List<FilterDefinition<ClientLocation>>(); | |
| list.Add(Builders<ClientLocation>.Filter.Where(a => a.ClientId == clientId)); | |
| if (startDate.HasValue) | |
| { | |
| list.Add(Builders<ClientLocation>.Filter.Where(a => a.CurrentTimeStamp >= startDate.Value)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task UpdateLocation(LocationRequest request) | |
| { | |
| var clientLocation = new ClientLocation | |
| { | |
| Id = Guid.NewGuid(), | |
| ClientId = request.ClientId, | |
| CurrentTimeStamp = request.CurrentTimeStamp, | |
| Coordinates = | |
| GeoJson.Point(new GeoJsonObjectArgs<GeoJson2DGeographicCoordinates>(), | |
| new GeoJson2DGeographicCoordinates(request.Longitude, request.Latitude)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LocationManager : ILocationManager | |
| { | |
| private readonly MongoClient _client; | |
| public LocationManager() | |
| { | |
| _client = new MongoClient("mongodb://localhost:27017"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface ILocationManager | |
| { | |
| Task UpdateLocation(LocationRequest request); | |
| Task<LocationResponse> RetrieveLocations(Guid clientId, DateTime? startDate = null, | |
| DateTime? endDate = null); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ClientLocation | |
| { | |
| public Guid Id { get; set; } | |
| public Guid ClientId { get; set; } | |
| public double Latitude { get; set; } | |
| public double Longitude { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LocationResponse | |
| { | |
| public Guid ClientId { get; set; } | |
| public LocationData[] Datas { get; set; } | |
| } | |
| public class LocationData | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LocationRequest | |
| { | |
| public double Latitude { get; set; } | |
| public double Longitude { get; set; } | |
| public Guid ClientId { get; set; } | |
| public DateTime CurrentTimeStamp { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class LocationRequest | |
| { | |
| public double Latitude { get; set; } | |
| public double Longitude { get; set; } | |
| public Guid ClientId { get; set; } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void Main(string[] args) | |
| { | |
| HostFactory.Run(x => | |
| { | |
| x.Service<LocationService>(s => | |
| { | |
| s.ConstructUsing(name => new LocationService()); | |
| //create the class that hosts service logic | |
| s.WhenStarted(a => a.Start()); //start method | |
| s.WhenStopped(a => a.Stop()); //stop method |
NewerOlder