Chimney.Shared.UserControls.ChimneyServerUserControl.InitDatabase C# (CSharp) Method

InitDatabase() public method

public InitDatabase ( string name ) : System.Threading.Tasks.Task
name string
return System.Threading.Tasks.Task
        public async Task InitDatabase(string name)
        {
            //
            // Check if the database is already exist
            //
            bool dbexist = await CheckDbAsync(name);

            //
            // Open the database, creating the database if it not already exist
            //
            Dbconnection = new SQLiteAsyncConnection(name);

            //
            // If the database is new create tables
            //
            if (!dbexist)
            {
                await Dbconnection.CreateTableAsync<File>();
                await Dbconnection.CreateTableAsync<Directory>();
                await Dbconnection.CreateTableAsync<Album>();
                await Dbconnection.CreateTableAsync<Artist>();
                await Dbconnection.CreateTableAsync<Genre>();
                await Dbconnection.CreateTableAsync<CurrentPlaylist>();
                await Dbconnection.CreateTableAsync<PlaylistFile>();
                await Dbconnection.CreateTableAsync<Playlist>();
                await Dbconnection.CreateTableAsync<AudioOutput>();

                AudioOutput newAudioOutput = new AudioOutput()
                {
                    Name = "Windows Phone Audio Output",
                    Enabled = true
                };

                await Dbconnection.InsertAsync(newAudioOutput);

                await Dbconnection.CreateTableAsync<Option>();

                Option newOption = new Option()
                {
                    Name = "repeat",
                    ValueBool = false
                };
                await Dbconnection.InsertAsync(newOption);

                newOption = new Option()
                {
                    Name = "random",
                    ValueBool = false
                };
                await Dbconnection.InsertAsync(newOption);

                newOption = new Option()
                {
                    Name = "consume",
                    ValueBool = false
                };
                await Dbconnection.InsertAsync(newOption);

                newOption = new Option()
                {
                    Name = "single",
                    ValueBool = false
                };
                await Dbconnection.InsertAsync(newOption);

                /*
                newOption = new Option()
                {
                    Name = "state",
                    ValueString = "stop"
                };
                await Dbconnection.InsertAsync(newOption);
                */
            }

            //
            // Check if empty start Directory exist
            //
            Directory startDirectory = await GetDirectory(string.Empty, 0);

            //
            // If not, create a empty start directory
            //
            // This is so MPD uri's should work in a easy way
            //
            if (startDirectory == null)
            {

                //
                // Create empty start parent Directory
                //
                startDirectory = new Directory()
                {
                    Name = string.Empty,
                    Path = string.Empty,
                    RelativePath = string.Empty,
                    ParentDirectoryId = 0,
                    FolderRelativeId = string.Empty
                };

                //
                // Add start Directory to Directories
                //
                await Dbconnection.InsertAsync(startDirectory);
            }
        }
ChimneyServerUserControl