Example #1
0
        public Location(
            ILocationInputFactory locationFactory,
            ITheme appliedTheme)
        {
#if NDEBUG
            var locationWindowControl = new LocationInputViewModel(appliedTheme)
            {
                LocationInputFields = new LocationInputFields(() => { })
                {
                    CityInput    = "Paris",
                    CountryInput = "France"
                }
            };
#else
            var locationWindowControl = locationFactory.Generate(appliedTheme);
            if (locationWindowControl == null)
            {
                return;
            }
#endif

            Country = locationWindowControl.LocationInputFields.CountryInput;
            City    = locationWindowControl.LocationInputFields.CityInput;

            WikiPageId      = locationWindowControl.WikiPageId;
            WeatherAreaCode = locationWindowControl.WeatherAreaCode;
        }
Example #2
0
        public LocationInput(LocationInputViewModel attachedViewModel)
        {
            InitializeComponent();
            DataContext = attachedViewModel;

            MouseLeftButtonDown += delegate { DragMove(); };
        }
        public async Task <IActionResult> OurLocation(LocationInputViewModel location)
        {
            if (!this.ModelState.IsValid)
            {
                this.ModelState.AddModelError(string.Empty, "Please, write valid coordinate");
                return(this.NotFound());
            }

            await this.locationsService.UpdateLocation(location);

            return(this.RedirectToAction("OurLocation"));
        }
        private bool SetLocation(
            LocationInputViewModel locationWindowControl,
            ITheme appliedTheme)
        {
            do
            {
                locationWindowControl.ClearInput();
                DisplayLocationInputWindow(locationWindowControl);
            } while (!locationWindowControl.IsValidCitySet() &&
                     ShouldContinueLocationSelection(appliedTheme));

            return(locationWindowControl.IsValidCitySet());
        }
        public ILocationInputViewModel Generate(ITheme currentTheme)
        {
            var locationWindowControl = new LocationInputViewModel(currentTheme);

            if (!SetLocation(
                    locationWindowControl,
                    currentTheme))
            {
                return(null);
            }

            return(locationWindowControl);
        }
Example #6
0
        public async Task UpdateLocation(LocationInputViewModel location)
        {
            var updateLocation = await this.repositoryLocation.All().FirstOrDefaultAsync(x => x.Id == location.Id);

            if (updateLocation != null)
            {
                this.repositoryLocation.Delete(updateLocation);

                updateLocation = new Location
                {
                    Id        = location.Id,
                    Latitude  = location.Latitude,
                    Longitude = location.Longitude,
                };

                await this.repositoryLocation.AddAsync(updateLocation);

                await this.repositoryLocation.SaveChangesAsync();
            }
        }
        private void DisplayLocationInputWindow(LocationInputViewModel locationWindowControl)
        {
            var locationWindow = new LocationInput(locationWindowControl);

            locationWindow.ShowDialog();
        }