Beispiel #1
0
        public virtual async Task RefreshItineraries(AmblOnGraph amblGraph, string entLookup, string username)
        {
            ensureStateObject();

            var userInfoResp = await amblGraph.GetUserInfo(username, entLookup);

            if (userInfoResp.Status)
            {
                State.UserInfo       = userInfoResp.Model;
                State.UserInfo.Email = username;
            }

            State.UserItineraries = await fetchUserItineraries(amblGraph, username, entLookup);

            State.Loading = false;
        }
        // public virtual async Task AddLocation(AmblOnGraph amblGraph, string username, string entLookup, UserLocation location)
        // {
        //     ensureStateObject();

        //     if (State.UserLayers.Any(x => x.ID == location.LayerID && !x.Shared))
        //     {
        //         var locationResp = await amblGraph.AddLocation(username, entLookup, location);

        //         if (locationResp.Status)
        //         {
        //             location.ID = locationResp.Model;

        //             if (State.SelectedUserLayerIDs.Contains(location.LayerID))
        //             {
        //                 State.VisibleUserLocations.Add(location);
        //                 State.AllUserLocations.Add(location);

        //                 var userMap = State.UserMaps.FirstOrDefault(x => x.ID == State.SelectedUserMapID);

        //                 if (userMap != null)
        //                     State.VisibleUserLocations = limitUserLocationsGeographically(State.VisibleUserLocations, userMap.Coordinates);

        //                 State.VisibleUserLocations = State.VisibleUserLocations.Distinct().ToList();
        //             }
        //         }
        //     }

        //     State.Loading = false;
        // }
        #endregion

        #region Delete

        // public virtual async Task DeleteLocation(AmblOnGraph amblGraph, string username, string entLookup, Guid locationID)
        // {
        //     ensureStateObject();

        //     var locationResp = await amblGraph.DeleteLocation(username, entLookup, locationID);

        //     if (locationResp.Status)
        //     {
        //         var existingVisible = State.VisibleUserLocations.FirstOrDefault(x => x.ID == locationID);

        //         if (existingVisible != null)
        //         {
        //             State.VisibleUserLocations.Remove(existingVisible);
        //             State.AllUserLocations.RemoveAll(item => item.ID == existingVisible.ID);
        //         }

        //         State.VisibleUserLocations = State.VisibleUserLocations.Distinct().ToList();
        //     }

        //     State.Loading = false;
        // }

        // public virtual async Task DedupLocationsByMap(AmblOnGraph amblGraph, string username, string entLookup, Guid mapID)
        // {
        //     ensureStateObject();

        //     var locationResp = await amblGraph.DedupLocationsByMap(username, entLookup, mapID);

        //     // Do not refresh state for now


        //     State.Loading = false;
        // }
        #endregion

        #region Edit

        // public virtual async Task EditLocation(AmblOnGraph amblGraph, string username, string entLookup, UserLocation location)
        // {
        //     ensureStateObject();

        //     if (State.UserLayers.Any(x => x.ID == location.LayerID && !x.Shared))
        //     {
        //         var locationResp = await amblGraph.EditLocation(username, entLookup, location);

        //         if (locationResp.Status)
        //         {
        //             if (State.SelectedUserLayerIDs.Contains(location.LayerID))
        //             {
        //                 var existingVisible = State.VisibleUserLocations.FirstOrDefault(x => x.ID == location.ID);

        //                 if (existingVisible != null)
        //                 {
        //                     State.VisibleUserLocations.Remove(existingVisible);
        //                     State.AllUserLocations.RemoveAll(item => item.ID == existingVisible.ID);
        //                 }

        //                 State.VisibleUserLocations.Add(location);
        //                 State.AllUserLocations.Add(location);

        //                 var userMap = State.UserMaps.FirstOrDefault(x => x.ID == State.SelectedUserMapID);

        //                 if (userMap != null)
        //                     State.VisibleUserLocations = limitUserLocationsGeographically(State.VisibleUserLocations, userMap.Coordinates);

        //                 State.VisibleUserLocations = State.VisibleUserLocations.Distinct().ToList();
        //             }
        //         }
        //     }

        //     State.Loading = false;
        // }

        #endregion

        public virtual async Task RefreshLocations(AmblOnGraph amblGraph, string entLookup, string username)
        {
            ensureStateObject();

            var userInfoResp = await amblGraph.GetUserInfo(username, entLookup);

            if (userInfoResp.Status)
            {
                State.UserInfo       = userInfoResp.Model;
                State.UserInfo.Email = username;
            }

            State.AllUserLocations = await amblGraph.PopulateAllLocations(username, entLookup);

            State.Loading = false;
        }