Exemplo n.º 1
0
        /// <summary>
        /// Saves the changes
        /// </summary>
        /// <returns></returns>
        public async Task <IFailable> SaveChangesAsync()
        {
            // Create the result
            var result = new Failable();

            try
            {
                // Get the directory path
                var directoryPath = Path.GetDirectoryName(OptionsFileName);

                // If the directory doesn't exist...
                if (!Directory.Exists(directoryPath))
                {
                    // Create it
                    Directory.CreateDirectory(directoryPath);
                }

                // Get the options
                var options = ToOptions();

                // Save the options
                XMLHelpers.ToXmlFile(options, OptionsFileName, new XmlWriterSettings());

                // Get the page builder
                var pageBuilder = CeidDiplomatikiDI.GetCeidDiplomatikiMainPageBuilder;

                // Refresh the main page
                pageBuilder.Refresh();
            }
            catch (Exception ex)
            {
                // Set the error
                result.ErrorMessage = ex.Message;
            }

            // Return the result
            return(await Task.FromResult(result));
        }