Example #1
0
        async Task SendAll()
        {
            for (var i = allEntries.Count - 1; i >= 0; i--)
            {
                if (!allEntries[i].Sent)
                {
                    var e = allEntries[i];
                    e.Active = true;
                    var sendResult = await sendService.SendEntry(e);

                    if (!sendResult)
                    {
                        unSentEntries.Add(e);
                        e.Active = false;
                    }
                    else
                    {
                        sentEntries.Add(e);
                        e.TimeSent = DateTime.Now;
                        e.Active   = false;
                        e.Sent     = true;
                        DataService.UpdateEntry(e);
                    }
                }
            }
        }
Example #2
0
        async Task Save()
        {
            EntryModel model = new EntryModel();

            if (ID != 0)
            {
                model.ID = ID;
            }
            model.Car     = Car.Num;
            model.Station = Station.Name;
            if (this.selectedHladbaerColas)
            {
                model.No = "VSB" + No;
            }
            else
            {
                model.No = No;
            }

            model.JobNo = (Double.Parse(JobNo)).ToString();
            // RoadWidth and RoadLength can be left unfilled
            if (RoadWidth != "")
            {
                model.RoadWidth = (Double.Parse(RoadWidth)).ToString();
            }
            else
            {
                model.RoadWidth = RoadWidth;
            }
            if (RoadLength != "")
            {
                model.RoadLength = (Double.Parse(RoadLength)).ToString();
            }
            else
            {
                model.RoadLength = RoadLength;
            }
            model.RoadArea    = (Double.Parse(RoadArea)).ToString();
            model.TarQty      = (Double.Parse(TarQty)).ToString();
            model.Rate        = (Double.Parse(Rate)).ToString();
            model.Degrees     = (Double.Parse(Degrees)).ToString();
            model.TimeCreated = DateTime.Now;
            model.StartTime   = StartTime;
            model.EndTime     = EndTime;
            model.Comment     = Comment;

            var sendResult = await sendService.SendEntry(model);

            if (sendResult)
            {
                model.TimeSent = DateTime.Now;
                model.Sent     = true;
                // Var það þannig að ef að það er entry i database-inum
                //með sama ID þá er ekki insertað heldur update-að?
                DataService.AddEntry(model);
                DependencyService.Get <IPopUp>().ShowToast("Sending tókst");
                //await Application.Current.MainPage.DisplayAlert("Sending tókst", "Færslan hefur verið send", "Loka");
            }
            else
            {
                model.TimeSent = null;
                model.Sent     = false;
                DataService.AddEntry(model);
                DependencyService.Get <IPopUp>().ShowToast("Sending mistókst");
                //await Application.Current.MainPage.DisplayAlert("Sending mistókst", "Ekki tókst að senda færslu", "Loka");
            }
        }