Ejemplo n.º 1
0
        internal async void ThisOnAppearing()
        {
            try
            {
                IsLoad = true;

                // verifica se tem internet
                if (Connectivity.NetworkAccess != NetworkAccess.Internet)
                {
                    await App.Current.MainPage.DisplayAlert("Informativo", "Sem Conexão com a Internet.", "ok");

                    return;
                }

                var location = await Geolocation.GetLastKnownLocationAsync();

                // pegou uma localização?
                if (location != null)
                {
                    Local = await ServiceHttp.GetCity(location.Latitude, location.Longitude).ConfigureAwait(false);

                    WeatherLocal = await ServiceHttp.GetWeather(location.Latitude, location.Longitude).ConfigureAwait(false);

                    Temperature     = Math.Round(WeatherLocal.Currently.Temperature, 0).ToString();
                    SensacaoTermica = Math.Round(WeatherLocal.Currently.ApparentTemperature, 0).ToString();
                    VentoVelocidade = Math.Round(WeatherLocal.Currently.WindSpeed, 2).ToString();
                    var list = WeatherLocal.Daily.Data;
                    Summary = WeatherLocal.Currently.Summary;

                    int cont = 1;
                    foreach (Datum datum in list)
                    {
                        if (cont == 7)
                        {
                            break;
                        }

                        datum.Day = String.Format(new CultureInfo("pt-BR"), "{0:dddd }", DateTime.Now.AddDays(cont));
                        Dailys.Add(datum);
                        cont++;
                    }
                }
                else
                {
                    Temperature = "-";
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                IsLoad = false;
            }
        }
Ejemplo n.º 2
0
        public double GetMonthlyRate()
        {
            double value = 0;

            if (Works != null)
            {
                foreach (var item in Works)
                {
                    Daily daily = Dailys
                                  .Where(p => p.Days
                                         .Contains(item.Day)).SingleOrDefault();
                    value += item.GetHours() * daily.HourlyRate;
                    if (Reprimand == false)
                    {
                        value += daily.Bonus;
                    }
                }
            }

            return(value);
        }