private async Task refreshPoisAsync() { string token = await _tokenService.GetAuthTokenAsync(); string userId = await _tokenService.GetUserIdAsync(); if (!string.IsNullOrEmpty(token)) { IsPoisLoaded = false; IsLoadingPoi = true; PoiApiRequest poiApi = new PoiApiRequest(token); var pois = await poiApi.GetMyPoisAsync(); PoiManager poiManager = new PoiManager(); pois.ForEach(p => { ViewPoi poi = new ViewPoi(p); poi.Save(); }); _pois = poiManager.GetAllAvailablePois(userId); await Task.WhenAll(_pois.Select(async p => await downloadPoiImgAsync(poiApi, p))); MainThread.BeginInvokeOnMainThread(() => { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("POIs")); IsPoisLoaded = !IsPoisLoaded; IsLoadingPoi = !IsLoadingPoi; }); } }
public void Load(string id) { PoiManager manager = new PoiManager(); LocalDB.Model.Poi poi = manager.GetPoiById(id); if (poi != null) { _id = poi.PoiId; _name = poi.Name; _createDate = poi.CreateDate; _updateDate = poi.UpdateDate; _address = poi.Address; _isPublished = poi.IsPublished; _isDeleted = poi.IsDeleted; _creatorId = poi.CreatorId; _byRoutePointId = poi.ByRoutePointId; _byRouteId = poi.ByRouteId; _description = poi.Description; _imgFilename = poi.ImgFilename; _imgBase64 = string.Empty; _likesCount = poi.LikesCount; _viewsCount = poi.ViewsCount; _position = new Position(poi.Latitude, poi.Longitude); } }
public async void StartDialog() { _vpoint.Refresh(_vpoint.Id); //Пока не знаю как поймать событие того, редактировалось описание на другой странице и вернулись на текущую уже с модифицированным описанием PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Description")); MessagingCenter.Subscribe <RoutePointDescriptionModifiedMessage>(this, string.Empty, (sender) => { if (sender.RoutePointId.Equals(_vpoint.Id)) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Description")); } }); MessagingCenter.Subscribe <MapSelectNewPointMessage>(this, string.Empty, (sender) => { setNewCoordinates(sender.Latitude, sender.Longitude); }); /*MessagingCenter.Subscribe<PageNavigationMessage>(this, string.Empty, (sender) => * { * if (sender.PageToOpen == MainPages.OverviewRouteMap) * { * MainThread.BeginInvokeOnMainThread(() => * { * var mapRoutePage = new MapRouteOverviewV2Page(_vpoint.RouteId); * Navigation.PushModalAsync(mapRoutePage, false); * }); * } * });*/ if ((_newPoint) && (_vpoint.Latitude == 0) && (_vpoint.Longitude == 0)) { var cacheCoordinates = await _geolocatorManager.GetLastKnownPosition(); if ((cacheCoordinates.Latitude != 0) && (cacheCoordinates.Longtitude != 0)) { Latitude = cacheCoordinates.Latitude; Longitude = cacheCoordinates.Longtitude; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Coordinates")); } var coordinates = await _geolocatorManager.GetCurrentLocationAsync(); if ((coordinates.Latitude != 0) && (coordinates.Longtitude != 0)) { Latitude = coordinates.Latitude; Longitude = coordinates.Longtitude; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Coordinates")); ApplyChanges(); await fillAddressAndPointName(Latitude, Longitude); ApplyChanges(); } } Device.StartTimer(TimeSpan.FromMilliseconds(100), OnTimerForUpdateLocation); MessagingCenter.Subscribe <PoiUpdatedMessage>(this, string.Empty, (sender) => { PoiManager poiManager = new PoiManager(); var vPoi = poiManager.GetPoiByRoutePointId(_vpoint.Id); if (!string.IsNullOrEmpty(vPoi.Id) && vPoi.Id.Equals(sender.PoiId)) { _vPoi = vPoi; IsPoiExists = true; } else { IsPoiExists = false; } }); await updatePoiStatusAsync(); }
private void Awake() { Debug.Log(TopLevelPoiList.Count); _instance = this; TopLevelPoiList = new List <PointOfInterest>(); }
public bool Save() { PoiManager manager = new PoiManager(); return(manager.Save(this)); }
private void deletePoi() { PoiManager poiManager = new PoiManager(); poiManager.Delete(_vpoi.Id); }