Exemple #1
0
        /// <summary>
        /// Creates the heater record.
        /// </summary>
        /// <returns><c>true</c>, if heater record was created, <c>false</c> otherwise.</returns>
        /// <param name="heater">Heater.</param>
        public bool createHeaterRecord(WaterHeater heater)
        {
            var           device        = Resolver.Resolve <IDevice>();
            NetworkStatus networkStatus = device.Network.InternetConnectionStatus();

            if (networkStatus == NetworkStatus.NotReachable)
            {
                return(false);
            }

            heaterTable.InsertAsync(heater);
            return(true);
        }
        async void SaveClicked(object sender, EventArgs e)
        {
            //Persist the new heater to the cloud
            WaterHeater heater = new WaterHeater
            {
                Capacity        = (int)capacity.Value,
                ManufactureYear = Int32.Parse(manufactured.Items[manufactured.SelectedIndex]),
                Manufacturer    = EnumUtil.ParseManufacturerString(manufacturer.Items[manufacturer.SelectedIndex]),
                HasSoftener     = hasSoftener.IsToggled
            };

            SyncManager manager = new SyncManager();
            bool        success = manager.createHeaterRecord(heater);

            if (!success)
            {
                await DisplayAlert("Network Error", "No network available, so heater was not created. Try again later.", "Ok");
            }

            await Navigation.PopAsync();
        }