protected AnalyticsBase(ApplicationPage appPage, IAggregateService aggregateService)
        {
            if (aggregateService == null)
                throw new ArgumentNullException("aggregateService");

            this.AggregateService = aggregateService; 
            this.appPage = appPage;
            if (appPage != ApplicationPage.SplashScreen)
                this.weather = UnitOfWork.WeatherRepository.Get();
        }
        protected virtual void UserLocationFound(GpsWatcherResponseMessage gpsWatcherResponseMessage)
        {
            if (gpsWatcherResponseMessage.Reason == GpsWatcherResponseMessageReason.Error)
            {
                DeregisterWatcher();

                this.ShowPopup(CustomPopupMessageType.Error, AppResources.CustomPopupGenericGpsFailureMessage, AppResources.CustomPopupGenericOkMessage, null);

                return;
            }

            if (SentCoordinateRequest || gpsWatcherResponseMessage.IsUsingLastKnown)
            {
                DeregisterWatcher();

                if (user != null && !gpsWatcherResponseMessage.IsUsingLastKnown)
                {
                    user.UpdateLocation(gpsWatcherResponseMessage.Coordinate);
                    UnitOfWork.UserRepository.Update(user);
                    UnitOfWork.Save();
                }

                if (InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.ShowWeather).Value)
                {
                    if (weather == null || weather.LastRefreshedDate < DateTime.Now.AddHours(-1))
                    {
                        Action getWeather = async () =>
                        {
                            try
                            {
                                IWeatherApi weatherApi = SimpleIoc.Default.GetInstance<IWeatherApi>();

                                if (weatherApi != null)
                                {
                                    weather = await weatherApi.GetDataWeather(gpsWatcherResponseMessage.Coordinate);

                                    UnitOfWork.WeatherRepository.DeleteAll();
                                    UnitOfWork.WeatherRepository.Insert(weather);
                                    UnitOfWork.Save();
                                }
                            }
                            catch (Exception)
                            {

                            }
                        };

                        DispatcherHelper.CheckBeginInvokeOnUI(getWeather);
                    }
                }
            }
        }