Пример #1
0
        ///<inheritdoc/>
        public Guid Save(ConnectorViewModel model)
        {
            var connectionInfo = new Resources.ConnectionInformation
            {
                InitialCatalog = model.InitialCatalog,
                DataSource     = model.DataSource,
                UserId         = model.UserId,
                Password       = model.Password
            };

            model.ConnectionString = _factory.CreateConnectionString(model.ResourceType, connectionInfo);

            Connector connector = _db.Connector.Find(model.Id);

            connector.Name             = model.Name;
            connector.ResourceType     = model.ResourceType;
            connector.Schema           = model.Schema;
            connector.ConnectionString = model.ConnectionString;
            connector.RecordLimit      = model.RecordLimit.Value;
            connector.UserId           = model.UserId;
            connector.InitialCatalog   = model.InitialCatalog;
            connector.DataSource       = model.DataSource;
            connector.Port             = model.Port;
            connector.IsActive         = model.IsActive;

            _db.SaveChanges();

            return(connector.Id);
        }
Пример #2
0
        ///<inheritdoc/>
        public Guid Insert(ConnectorViewModel model)
        {
            var connectionInfo = new Resources.ConnectionInformation
            {
                InitialCatalog = model.InitialCatalog,
                DataSource     = model.DataSource,
                UserId         = model.UserId,
                Password       = model.Password
            };

            model.ConnectionString = _factory.CreateConnectionString(model.ResourceType, connectionInfo);

            Connector connector = new Connector
            {
                Name             = model.Name,
                ResourceType     = model.ResourceType,
                Schema           = model.Schema,
                ConnectionString = model.ConnectionString,
                RecordLimit      = model.RecordLimit.Value,
                UserId           = model.UserId,
                InitialCatalog   = model.InitialCatalog,
                DataSource       = model.DataSource,
                Port             = model.Port,
                IsActive         = model.IsActive
            };

            _db.Connector.Add(connector);

            _db.SaveChanges();

            return(connector.Id);
        }