Beispiel #1
0
        private Measurement FindLastMeasurment(WeightEvent mes)
        {
            Measurement m = new Measurement();

            if (mes.Date < Measurements[Measurements.Count - 1].MeasurementDate)
            {
                m.Weight          = mes.Weight;
                m.MeasurementDate = mes.Date;
            }
            else
            {
                m = Measurements.Where(d => d.MeasurementDate <= mes.Date).First();
            }

            return(m);
        }
 private void Button_Clicked(object sender, EventArgs e)
 {
     if (isFormValid())
     {
         double weightdob = 0;
         if (Double.TryParse(weightEntry.Text, out weightdob))
         {
             PopupNavigation.Instance.PopAsync();
             WeightEvent weight = new WeightEvent(datePicker.Date, double.Parse(weightEntry.Text));
             weight.Weight = Math.Round(weight.Weight, 1);
             MessagingCenter.Send <WeightEvent>(weight, "Added weight");
         }
         else
         {
         }
     }
     else
     {
     }
 }
Beispiel #3
0
        private async void AddWeight(WeightEvent obj)
        {
            double date   = DateTimeAxis.ToDouble(obj.Date);
            double weight = obj.Weight;
            var    point  = new DataPoint(date, weight);
            // here we will add to DB not local serie
            Measurement newMeasurment = new Measurement();

            if (Measurements.Count == 0)
            {
                newMeasurment.MeasurementDate = obj.Date;
                newMeasurment.Weight          = weight;
            }
            else
            {
                Measurement lastMeasurement = new Measurement();
                lastMeasurement = FindLastMeasurment(obj);
                newMeasurment.MeasurementDate = obj.Date;
                newMeasurment.Weight          = weight;
            }
            await DatabaseMethods.AddMeasurementToDatabase(newMeasurment);

            await HandleDatabaseRequest();
        }