Beispiel #1
0
        /// <summary>
        /// Add a new unit to the webservice and reload ws units list
        /// Or Add it to the local units list
        /// save the list localy
        /// </summary>
        /// <param name="unit">new unit to add in Units</param>
        public async static void SaveUnit(Unit unit)
        {
            try
            {
                if (Units == null)
                {
                    await LoadUnits();
                }

                Units = await WSConsumer.AddUnit(unit);
            }
            catch (Exception e)
            {
                DependencyService.Get <IMessage>().longtime("ERR: " + e.Message);
                if (Units == null)
                {
                    Units = new List <Unit>();
                }

                Units.Add(unit);
            }
            SaveList(Units, unitFile);
        }