/// <summary> /// Inserts the type of the integration service exposed. /// </summary> /// <param name="dto">The dto.</param> /// <exception cref="System.ArgumentNullException">dto</exception> /// <exception cref="System.Data.DBConcurrencyException"></exception> public void InsertIntegrationServiceExposedType(IntegrationServiceExposedTypeDto dto) { const string CommandText = @" INSERT INTO [dbo].[IntegrationServiceExposedTypes] ( [SettingsId] ,[LastModifiedOn] ,[Guid] ,[Name] ,[Namespace] ) VALUES ( @settingsId ,GETDATE() ,@guid ,@name ,@namespace ); SET @id = SCOPE_IDENTITY();"; if (dto == null) throw new ArgumentNullException("dto"); using (var cmd = new SqlCommand(CommandText)) { var idParam = cmd.Parameters.Add("@id", SqlDbType.Int); idParam.Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@settingsId", dto.SettingsId); cmd.Parameters.AddWithValue("@guid", dto.Guid); cmd.Parameters.AddWithValue("@name", dto.Name); cmd.Parameters.AddWithValue("@namespace", dto.Namespace); var rowsAffected = Database.Execute(cmd); if (rowsAffected == 0) throw new DBConcurrencyException(ConcurencyException); dto.Id = (int)idParam.Value; } }
/// <summary> /// Updates the type of the integration service exposed. /// </summary> /// <param name="dto">The dto.</param> /// <exception cref="System.ArgumentNullException">dto</exception> /// <exception cref="System.Data.DBConcurrencyException"></exception> public void UpdateIntegrationServiceExposedType(IntegrationServiceExposedTypeDto dto) { const string CommandText = @" UPDATE [dbo].[IntegrationServiceExposedTypes] SET [SettingsId] = @settingsId ,[LastModifiedOn] = GETDATE() ,[Guid] = @guid ,[Name] = @name ,[Namespace] = @namespace WHERE [Id] = @id;"; if (dto == null) throw new ArgumentNullException("dto"); using (var cmd = new SqlCommand(CommandText)) { cmd.Parameters.AddWithValue("@id", dto.Id); cmd.Parameters.AddWithValue("@settingsId", dto.SettingsId); cmd.Parameters.AddWithValue("@guid", dto.Guid); cmd.Parameters.AddWithValue("@name", dto.Name); cmd.Parameters.AddWithValue("@namespace", dto.Namespace); var rowsAffected = Database.Execute(cmd); if (rowsAffected == 0) throw new DBConcurrencyException(ConcurencyException); } }
/// <summary> /// Reads the integration service exposed types. /// </summary> /// <param name="settingsDto">The settings dto.</param> /// <param name="reader">The reader.</param> private static void ReadIntegrationServiceExposedTypes(IntegrationServiceCreationSettingsDto settingsDto, IDataReader reader) { reader.NextResult(); while (reader.Read()) { var dto = new IntegrationServiceExposedTypeDto { Id = reader.GetInt32(0), Guid = reader.GetGuid(1), Name = reader.GetString(2), Namespace = reader.GetString(3) }; settingsDto.Types.Add(dto); } ReadIntegrationServiceExposedTypeFields(settingsDto, reader); }