//TODO: Violation of one rensponsibility rule
        public async Task <bool> MergeAsync(string fileId, DateTime currentDate, Func <DataSet, DateTime> readDate)
        {
            await Online.AuthorizeAsync();

            if (!CheckConnection())
            {
                return(false);
            }

            byte[] raw;
            try
            {
                raw = Online.Downloader.Download(Online.Credentials, fileId);
                if (raw == null)
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }

            DataSet update;

            using (Stream s = new MemoryStream(raw))
            {
                update = new DataSet();
                update.ReadXml(s, XmlReadMode.Auto);
            }

            // check modified date.
            var     updateDate = readDate(update);
            DataSet src, dest;

            if (updateDate > currentDate)
            {
                src  = Storage;
                dest = update;
            }
            else
            {
                src  = update;
                dest = Storage;
            }

            src.Merge(dest, true, MissingSchemaAction.AddWithKey);

            Storage = src;
            return(true);
        }
        //TODO: Violation of one rensponsibility rule
        public async Task <bool> RestoreAsync(string fileId)
        {
            if (Online == null)
            {
                return(false);
            }

            await Online.AuthorizeAsync();

            byte[] raw;
            try
            {
                raw = Online.Downloader.Download(Online.Credentials, fileId);
                if (raw == null)
                {
                    return(false);
                }
            }
            catch
            {
                //TODO: write good message here
                throw;
            }

            using (Stream s = new MemoryStream(raw))
            {
                var onlineStorage = new DataSet();
                onlineStorage.ReadXml(s, XmlReadMode.Auto);
                onlineStorage.AcceptChanges();
                //TODO: merge

                /*
                 * if (Storage != null)
                 *      Storage.Merge(onlineStorage, true, MissingSchemaAction.AddWithKey);
                 * else
                 *      Storage = onlineStorage;
                 */
                Storage = onlineStorage;
            }

            return(true);
        }
        //TODO: Violation of one rensponsibility rule
        public async Task <bool> BackupAsync(string fileId, bool exists)
        {
            if (!CheckConnection() || Online == null)
            {
                return(false);
            }

            await Online.AuthorizeAsync();

            Save(ConnectionString);
            var raw = File.ReadAllBytes(ConnectionString);

            try
            {
                Online.Uploader.Upload(Online.Credentials, raw, fileId, exists);
                return(true);
            }
            catch
            {
                throw;
            }
        }