public async void RenameLocation_ShouldSaveDbContextChanges() { // Arrange SetUp(); var payload = new Location { Id = 2, Name = "NewLocName" }; var locationInDb = new Location { Id = 2 }; _context.Locations.Returns(new List <Location> { locationInDb }); // Act var sit = new LocationDataService(_factory); var result = await sit.RenameLocationAsync(payload.Id, payload.Name); // Assert _context.Received().SaveChanges(); Assert.Equal(payload.Name, result.Name); }
public async void GetAllLocations_ShouldReadFromDbContext() { // Arrange SetUp(); var locationsInDb = new List <Location> { new Location { Id = 1 }, new Location { Id = 2 }, new Location { Id = 3 } }; _context.Locations.Returns(locationsInDb); // Act var sit = new LocationDataService(_factory); var results = (await sit.GetAllLocationsAsync()).ToList(); // Assert Assert.Equal(locationsInDb[0].Id, results[0].Id); Assert.Equal(locationsInDb[1].Id, results[1].Id); Assert.Equal(locationsInDb[2].Id, results[2].Id); }
public IHttpActionResult AddLocation(LocationModel locatioModel) { // To call this method: http://localhost:12345/Api/LocationData/AddLocation DeviceDataService deviceDataService = new DeviceDataService(); var device = deviceDataService.Get(locatioModel.DeviceId); if (device == null) { return(Json("Toks įrenginys neegzistuoja")); } else { LocationDataService locationDataService = new LocationDataService(); Location location = new Location { Longitude = locatioModel.Longitude, Latitude = locatioModel.Latitude, TimeStamp = locatioModel.TimeStamp, DeviceId = device.Id }; locationDataService.Add(location); var jsonLocation = new { latitude = locatioModel.Latitude, longitude = locatioModel.Longitude }; var options = new PusherOptions { Cluster = "eu", Encrypted = true }; var _pusher = new Pusher( "526323", "e3eb2284cbb62f35599f", "52decc2ad70da06be4d0", options); _pusher.TriggerAsync("location_channel", "new_location", jsonLocation); GeofencingServices geofencingServices = new GeofencingServices(); geofencingServices.CheckGeofence(locatioModel.Longitude, locatioModel.Latitude, locatioModel.DeviceId); return(Json(new { status = "success", data = location })); } }
public LoginPageActivity() { mAccountDataService = new AccountDataService(); mInventoryDataService = new InventoryDataService(); mProductDataService = new ProductDataService(); mStorageDataService = new StorageDataService(); mLocationDataService = new LocationDataService(); mCategoryDataService = new CategoryDataService(); mConsumeDataService = new ConsumeDataService(); mUserDataDataService = new UserDataDataService(); mUserLocationDataService = new UserLocationDataService(); }
public HomeFragment() { mLocationDataService = new LocationDataService(); mInventoryDataService = new InventoryDataService(); mProductDataService = new ProductDataService(); mStorageDataService = new StorageDataService(); mInventories = new List <InventoryViewModel>(); mProducts = new List <ProductViewModel>(); mStorages = new List <StorageViewModel>(); mLocations = new List <LocationViewModel>(); mUserLoc = new List <UserLocationViewModel>(); }
public SplashScreenActivity() { mAccountDataService = new AccountDataService(); mInventoryDataService = new InventoryDataService(); mProductDataService = new ProductDataService(); mStorageDataService = new StorageDataService(); mLocationDataService = new LocationDataService(); mCategoryDataService = new CategoryDataService(); mConsumeDataService = new ConsumeDataService(); mUserDataDataService = new UserDataDataService(); mUserLocationDataService = new UserLocationDataService(); mShopListDataService = new ShoplistDataService(); mShopItemDataService = new ShopItemDataService(); }
private void AddLocationAlerts() { LocationDataService locationService = new LocationDataService(); List <LocationModel> locations = new List <LocationModel>(); locations = locationService.GetFakeLocations(); foreach (LocationModel location in locations) { //Setting up My Broadcast Intent AddProximityAlert(location.Name, location.Latitude, location.Longitude, location.Radius); } }
public ActionResult Index(int id) { DeviceDataService deviceDataService = new DeviceDataService(); var device = deviceDataService.Get(id); LocationDataService locationDataService = new LocationDataService(); var locations = locationDataService.GetAllByDevice(device.Id); if (locations.Count == 0) { return(View("NoLocationsAvailable")); } else { return(View(locations)); } }
public async void RemoveLocation_ShouldRemoveFromDbContext() { // Arrange SetUp(); var locationInDb = new Location { Id = 2 }; _context.Locations.Returns(new List <Location> { locationInDb }); // Act var sit = new LocationDataService(_factory); await sit.RemoveLocationAsync(2); // Assert _context.Received().Remove(locationInDb); }
public async void AddLocation_ShouldAddToDbContext() { // Arrange SetUp(); var toAdd = new Location { Id = 2 }; var payload = new Location { Id = 2, Name = "NewLocName" }; // Act var sit = new LocationDataService(_factory); await sit.AddLocationAsync(toAdd); // Assert _context.Received().Add(toAdd); }
public ActionResult Sort(int id, int time) { LocationDataService locationDataService = new LocationDataService(); var locations = locationDataService.GetAllByDevice(id); List <Location> sortedList = new List <Location>(); var now = DateTime.Now; foreach (var location in locations) { if ((now - location.TimeStamp).TotalMinutes <= (time * 60)) { sortedList.Add(location); } } //if no sorting can be made by that time, the last known place is shown if (sortedList.Count == 0) { sortedList.Add(locations[locations.Count - 1]); } return(View("Index", sortedList)); }
public LocationEditFragment() { mLocationDataService = new LocationDataService(); userLocationDataService = new UserLocationDataService(); }
public CategoryEditFragment() { mLocationDataService = new LocationDataService(); }
public LocationActivity() { mLocationDataService = new LocationDataService(); }
public HomeController(MyDbContext db) { LocationDataAccessLayer = new LocationDataService(db); }
protected void UpdateLocationChanges() { LocationDataService.Update(Event.LocationId, Event.Location); }
public LocationsFragment() { mLocationDataService = new LocationDataService(); }