private async void InitializeDatabase() { productsDb = new DbConnectionManager("ProductDB.db3"); jobsDb = new DbConnectionManager("JobDB.db3"); // updating database from online if there is an updated version available. bool update = false; update = await DataAccess.OnlineUpdater.UpdateAvailable(); if (update) { await DataAccess.OnlineUpdater.UpdateAll(); Debug.WriteLine("--== database updated ==--"); } else { Debug.WriteLine("--== no database update required ==--"); } }
public AccordionViewModel(INavigation navigation) { trafficPane = null; calendarPane = null; weatherPane = null; locationAreaPane = null; this.Calculate = new Command(async(nothing) => { if (!calculateTapped) { calculateTapped = true; // double check the inputs (length, width, location) if (!validateInputs()) { // terminate the process calculateTapped = false; return; } Job newJob = new Job() { Area = area, AreaTypeID = (int)App.TrafficOption, CreationDate = DateTime.Now, WillRain = (App.WeatherOption == WeatherOptions.RainExpected), JobType = (int)App.IndustryOption, DurationMaxDays = (int)App.DurationOption, Location = Location }; //quick and nasty fix for calc issue. page is still buggy. //job area will be saved as sq metre if (areaUnit == Units.Kilometre) { newJob.Area = newJob.Area * 1000000; } if (Settings.EnableAnalytics) { //Starts Analytics up AnalyticsClass.SetDetails(); //Send all needed data AnalyticsClass.SendAnalytics(App.IndustryOption.ToString(), "Traffic", App.TrafficOption.ToString(), "Calendar", App.DurationOption.ToString(), "Rain", App.WeatherOption.ToString(), "Location", Location); } App.JobsDb.DbConnection.Insert(newJob); ProductViewModel productViewModel = new ProductViewModel(); DbConnectionManager productsDB = App.ProductsDb; IEnumerable <ProductMatrix> productSelection = productsDB.SelectProducts((int)App.DurationOption, (int)App.TrafficOption, (App.WeatherOption == WeatherOptions.RainExpected)); foreach (ProductMatrix productMatrix in productSelection) { ProductDescription productDescription = productsDB.GetProductInfo(productMatrix); productViewModel.Products.Add(new ProductResult() { Job = newJob, Description = productDescription }); if (productViewModel.Products.Count > 0) { productViewModel.SelectedProduct = productViewModel.Products[0]; } } await navigation.PushAsync(new ProductPage(productViewModel)); calculateTapped = false; } }); this.ChangeLengthUnit = new Command((nothing) => { if (LengthUnit == Units.Metre) { LengthUnit = Units.Kilometre; } else { LengthUnit = Units.Metre; } setArea(); }); this.ChangeWidthUnit = new Command((nothing) => { if (WidthUnit == Units.Metre) { WidthUnit = Units.Kilometre; } else { WidthUnit = Units.Metre; } setArea(); }); this.ChangeAreaUnit = new Command((nothing) => { if (AreaUnit == Units.Metre) { AreaUnit = Units.Kilometre; } else { AreaUnit = Units.Metre; } if (areaUntouched == area) { setArea(); } }); }