/// <summary>
        /// Removes the selected datasets from database.
        /// </summary>
        /// <param name="datasetBindingList">The dataset binding list.</param>
        /// <param name="selectedDatasets">The selected datasets.</param>
        /// <returns>True if OK, else False</returns>
        public static bool RemoveDatasets(List <Dataset> datasetBindingList, IList <int> selectedDatasets)
        {
            using (var localDb = new GeosyncDbEntities())
            {
                foreach (var selected in selectedDatasets)
                {
                    var geoClientDataset = datasetBindingList[selected];

                    var dataset =
                        (from d in localDb.Dataset where d.DatasetId == geoClientDataset.DatasetId select d)
                        .FirstOrDefault();
                    if (dataset == null)
                    {
                        return(false);
                    }
                    try
                    {
                        localDb.DeleteObject(dataset);
                        localDb.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex, "Error removing selected datasets!");
                        return(false);
                    }
                }
            }

            return(true);
        }
        public static bool AddDatasets(IBindingList datasetBindingList, IList <int> selectedDatasets, string providerUrl,
                                       string userName, string password)
        {
            using (var localDb = new GeosyncDbEntities())
            {
                foreach (var selected in selectedDatasets)
                {
                    var ds = (Dataset)datasetBindingList[selected];
                    try
                    {
                        ds.LastIndex         = 0;
                        ds.ClientWfsUrl      = "";
                        ds.UserName          = userName;
                        ds.Password          = password;
                        ds.SyncronizationUrl = providerUrl;
                        localDb.AddObject(ds);
                        localDb.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex, "Error saving selected datasets!");
                        return(false);
                    }
                }
            }

            return(true);
        }
        public static bool AddEmptyDataset()
        {
            using (var localDb = new GeosyncDbEntities())
            {
                var ds = new Dataset();
                try
                {
                    ds.LastIndex    = 0;
                    ds.ClientWfsUrl = "";
                    localDb.AddObject(ds);
                    localDb.SaveChanges();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "Error saving selected datasets!");
                    return(false);
                }
            }

            return(true);
        }
        public static bool UpdateDataset(Dataset geoClientDataset)
        {
            using (var localDb = new GeosyncDbEntities())
            {
                var dataset =
                    (from d in localDb.Dataset where d.DatasetId == geoClientDataset.DatasetId select d)
                    .FirstOrDefault();
                if (dataset == null)
                {
                    return(false);
                }

                dataset.MaxCount             = geoClientDataset.MaxCount;
                dataset.LastIndex            = geoClientDataset.LastIndex;
                dataset.Name                 = geoClientDataset.Name;
                dataset.ProviderDatasetId    = geoClientDataset.ProviderDatasetId;
                dataset.SyncronizationUrl    = geoClientDataset.SyncronizationUrl;
                dataset.ClientWfsUrl         = geoClientDataset.ClientWfsUrl;
                dataset.TargetNamespace      = geoClientDataset.TargetNamespace;
                dataset.MappingFile          = geoClientDataset.MappingFile;
                dataset.AbortedEndIndex      = geoClientDataset.AbortedEndIndex;
                dataset.AbortedTransaction   = geoClientDataset.AbortedTransaction;
                dataset.AbortedChangelogPath = geoClientDataset.AbortedChangelogPath;
                dataset.ChangelogDirectory   = geoClientDataset.ChangelogDirectory;
                dataset.AbortedChangelogId   = geoClientDataset.AbortedChangelogId;
                dataset.UserName             = geoClientDataset.UserName;
                if (geoClientDataset.Password != "******")
                {
                    dataset.Password = geoClientDataset.Password;
                }
                dataset.Version = geoClientDataset.Version;

                localDb.SaveChanges();
                return(true);
            }
        }