Esempio n. 1
0
 private void InitListViewModel(UserItemsViewModel viewModel, UserItems list)
 {
     foreach (var item in viewModel.Items)
     {
         InitBaseItemViewModel(item);
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> ShowUserItems(string date = "")
        {
            var model = new UserItemsViewModel();

            //model.UserEvents = await _userService.GetUserEvents(_userId, date);
            //model.UserFollows = await _userService.GetUserFollows(_userId, date);
            //model.UserNotes = await _userService.GetUserNotes(_userId, date);
            return(ViewComponent("ShowUserItems", model));
        }
Esempio n. 3
0
        public ActionResult List(UserFilterViewModel filterViewModel)
        {
            InitUserFilterViewModel(ref filterViewModel, true);
            var                filter    = Mapper.Map <UserFilter>(filterViewModel);
            UserItems          list      = _userRepository.GetUserItems(UserContext.User.Id, UserContext.User.OrganizationId, filter);
            UserItemsViewModel viewModel = Mapper.Map <UserItemsViewModel>(list);

            viewModel.Filter = filterViewModel;
            InitListViewModel(viewModel, list);

            return(View(Mvc.View.User.List, viewModel));
        }
Esempio n. 4
0
        /// <summary>
        /// Loads the AuthUserItemsPage and changes map when user selects an item
        /// </summary>
        private async void LoadUserItems(object sender, EventArgs e)
        {
            _userItemsViewModel = new UserItemsViewModel();
            await _userItemsViewModel.LoadUserItems();

            // Change map when user selects a new user item
            _userItemsViewModel.PropertyChanged += async(s, ea) =>
            {
                switch (ea.PropertyName)
                {
                case nameof(UserItemsViewModel.SelectedUserItem):
                {
                    // Set the viewpoint of the new map to be the same as the old map
                    // Otherwise map is being reset to the world view
                    var mapViewModel     = Resources["MapViewModel"] as MapViewModel;
                    var currentViewpoint = MapView.GetCurrentViewpoint(ViewpointType.CenterAndScale);

                    try
                    {
                        var newMap = new Map(_userItemsViewModel.SelectedUserItem)
                        {
                            InitialViewpoint = currentViewpoint
                        };

                        //Load new map
                        await newMap.LoadAsync();

                        mapViewModel.Map = newMap;
                    }
                    catch (Exception ex)
                    {
                        mapViewModel.ErrorMessage = "Unable to change maps";
                        mapViewModel.StackTrace   = ex.ToString();
                    }

                    break;
                }
                }
            };

            SettingsPanel.IsVisible = false;

            // Load the AuthUserItemsPage
            await Navigation.PushAsync(new AuthUserItemsPage { BindingContext = _userItemsViewModel });
        }
Esempio n. 5
0
        /// <summary>
        /// List all blobs in a container
        /// </summary>
        /// <param name="containerName">Name of the container to get the blobs from</param>
        /// <returns>List of blobs in the container</returns>
        public async Task <UserItemsViewModel> ListPublicAsync(string containerName)
        {
            // Get a reference to a container
            BlobContainerClient container = new BlobContainerClient(_connectionString, containerName);
            await container.CreateIfNotExistsAsync();

            // List all the blobs
            var blobs = new UserItemsViewModel();

            await foreach (BlobItem blob in container.GetBlobsAsync())
            {
                blob.Metadata.TryGetValue("extension", out string extension);

                blobs.Items.Add(new UserItemViewModel
                {
                    Name          = blob.Name,
                    Uri           = container.Uri.ToString(),
                    FileExtension = extension ?? "Unknown"
                });
            }

            return(blobs);
        }
        public ActionResult UserItems(string UserId)
        {
            var model = new UserItemsViewModel(UserId);

            return(View(model));
        }
Esempio n. 7
0
 public IViewComponentResult Invoke(UserItemsViewModel model)
 {
     return View(model);
 }
Esempio n. 8
0
        /// <summary>
        /// Performs initialization
        /// </summary>
        private async void Initialize()
        {
            try
            {
                var routeStyle = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.FromArgb(0x00, 0x79, 0xc1), 5);
                RouteRenderer.Symbol = routeStyle;

                PictureMarkerSymbol endMapPin = await CreateMapPin("end.png");

                PictureMarkerSymbol startMapPin = await CreateMapPin("start.png");

                var geocodeViewModel     = Resources["GeocodeViewModel"] as GeocodeViewModel;
                var fromGeocodeViewModel = Resources["FromGeocodeViewModel"] as GeocodeViewModel;
                var toGeocodeViewModel   = Resources["ToGeocodeViewModel"] as GeocodeViewModel;
                _routeViewModel     = Resources["RouteViewModel"] as RouteViewModel;
                _basemapViewModel   = Resources["BasemapsViewModel"] as BasemapsViewModel;
                _userItemsViewModel = Resources["UserItemsViewModel"] as UserItemsViewModel;

                geocodeViewModel.PropertyChanged += (o, e) =>
                {
                    switch (e.PropertyName)
                    {
                    case nameof(GeocodeViewModel.Place):
                    {
                        var graphicsOverlay = MapView.GraphicsOverlays["PlacesOverlay"];
                        graphicsOverlay?.Graphics.Clear();

                        GeocodeResult place = geocodeViewModel.Place;
                        if (place == null)
                        {
                            return;
                        }

                        var graphic = new Graphic(geocodeViewModel.Place.DisplayLocation, endMapPin);
                        graphicsOverlay?.Graphics.Add(graphic);

                        break;
                    }
                    }
                };

                fromGeocodeViewModel.PropertyChanged += (o, e) =>
                {
                    switch (e.PropertyName)
                    {
                    case nameof(GeocodeViewModel.Place):
                    {
                        _routeViewModel.FromPlace = fromGeocodeViewModel.Place;
                        break;
                    }
                    }
                };

                toGeocodeViewModel.PropertyChanged += (o, e) =>
                {
                    switch (e.PropertyName)
                    {
                    case nameof(GeocodeViewModel.Place):
                    {
                        _routeViewModel.ToPlace = toGeocodeViewModel.Place;
                        break;
                    }
                    }
                };

                _routeViewModel.PropertyChanged += (s, e) =>
                {
                    switch (e.PropertyName)
                    {
                    case nameof(RouteViewModel.Route):
                    {
                        var graphicsOverlay = MapView.GraphicsOverlays["RouteOverlay"];

                        // clear existing graphics
                        graphicsOverlay?.Graphics?.Clear();

                        if (_routeViewModel.FromPlace == null || _routeViewModel.ToPlace == null ||
                            _routeViewModel.Route == null || graphicsOverlay == null)
                        {
                            return;
                        }

                        // Add route to map
                        var routeGraphic = new Graphic(_routeViewModel.Route.Routes.FirstOrDefault()?.RouteGeometry);
                        graphicsOverlay?.Graphics.Add(routeGraphic);

                        // Add start and end locations to the map
                        var fromGraphic = new Graphic(_routeViewModel.FromPlace.RouteLocation, startMapPin);
                        var toGraphic   = new Graphic(_routeViewModel.ToPlace.RouteLocation, endMapPin);
                        graphicsOverlay?.Graphics.Add(fromGraphic);
                        graphicsOverlay?.Graphics.Add(toGraphic);

                        break;
                    }
                    }
                };

                // start location services - only once MapView.LocationDisplay property is ready
                MapView.PropertyChanged += (o, e) =>
                {
                    if (e.PropertyName == nameof(MapView.LocationDisplay) && MapView.LocationDisplay != null)
                    {
                        var mapViewModel = Resources["MapViewModel"] as MapViewModel;
                        MapView.LocationDisplay.DataSource  = mapViewModel.LocationDataSource;
                        MapView.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Recenter;

#if __ANDROID__
                        MainActivity.Instance.AskForLocationPermission(MapView);
#else
                        MapView.LocationDisplay.IsEnabled = true;
#endif
                    }
                };

                // Change map when user selects a new basemap
                _basemapViewModel.PropertyChanged += (s, ea) =>
                {
                    switch (ea.PropertyName)
                    {
                    case nameof(BasemapsViewModel.SelectedBasemap):
                    {
                        // Set the viewpoint of the new map to be the same as the old map
                        // Otherwise map is being reset to the world view
                        var mapViewModel = Resources["MapViewModel"] as MapViewModel;

                        try
                        {
                            var currentViewpoint = MapView.GetCurrentViewpoint(ViewpointType.CenterAndScale);
                            mapViewModel.Map.Basemap = new Basemap(_basemapViewModel.SelectedBasemap);
                        }
                        catch (Exception ex)
                        {
                            mapViewModel.ErrorMessage = "Unable to change basemaps";
                            mapViewModel.StackTrace   = ex.ToString();
                        }

                        break;
                    }
                    }
                };

                // Change map when user selects a new user item
                _userItemsViewModel.PropertyChanged += async(s, ea) =>
                {
                    switch (ea.PropertyName)
                    {
                    case nameof(UserItemsViewModel.SelectedUserItem):
                    {
                        // Set the viewpoint of the new map to be the same as the old map
                        // Otherwise map is being reset to the world view
                        var mapViewModel     = Resources["MapViewModel"] as MapViewModel;
                        var currentViewpoint = MapView.GetCurrentViewpoint(ViewpointType.CenterAndScale);

                        try
                        {
                            var newMap = new Map(_userItemsViewModel.SelectedUserItem)
                            {
                                InitialViewpoint = currentViewpoint
                            };

                            //Load new map
                            await newMap.LoadAsync();

                            mapViewModel.Map = newMap;
                        }
                        catch (Exception ex)
                        {
                            mapViewModel.ErrorMessage = "Unable to change maps";
                            mapViewModel.StackTrace   = ex.ToString();
                        }

                        break;
                    }
                    }
                };


#if __IOS__
                // This is necessary because on iOS the SearchBar doesn't get unfocused automatically when a geocode result is selected
                SearchSuggestionsList.ItemSelected += (s, e) =>
                {
                    AddressSearchBar.Unfocus();
                };

                FromLocationSuggestionsList.ItemSelected += (s, e) =>
                {
                    FromLocationTextBox.Unfocus();
                };

                ToLocationSuggestionsList.ItemSelected += (s, e) =>
                {
                    ToLocationTextBox.Unfocus();
                };
#endif
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.ToString(), "OK");
            }
        }