/// <summary> /// Updates process command. /// </summary> /// <param name="dto">The DTO object.</param> /// <param name="locDto">The localization DTO object.</param> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.Data.DBConcurrencyException"></exception> /// <exception cref="DBConcurrencyException">Indicates stale data.</exception> public void UpdateProcessCommandWithLocalization(ProcessCommandEditDto dto, ProcessCommandLocalizationDto locDto) { if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); const string CommandText = @" UPDATE [dbo].[Commands] SET [LastModifiedOn] = @p_LastModifiedOn ,[GuidId] = @p_GuidId ,[ProcessId] = @p_ProcessId ,[CommandType] = @p_CommandType ,[IntegrationServiceGuid] = @p_IntegrationServiceGuid ,[DataTriggerGuid] = @p_DataTriggerGuid WHERE [Id] = @p_Id; "; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_Id", dto.Id); command.Parameters.AddWithValue("@p_LastModifiedOn", dto.LastModifiedOn); command.Parameters.AddWithValue("@p_GuidId", dto.GuidId); command.Parameters.AddWithValue("@p_ProcessId", dto.ProcessId); command.Parameters.AddWithValue("@p_CommandType", dto.CommandType); command.Parameters.AddWithValue("@p_IntegrationServiceGuid", AdoHelper.NullCheck(dto.IntegrationServiceGuid)); command.Parameters.AddWithValue("@p_DataTriggerGuid", AdoHelper.NullCheck(dto.DataTriggerGuid)); if (command.ExecuteNonQuery() == 0) { throw new DBConcurrencyException(Resources.StaleDataException); } } } UpdateProcessCommandLocalization(locDto); }
/// <summary> /// Inserts process command. /// </summary> /// <param name="dto">The DTO object.</param> /// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentException">The input DTO is null.</exception> public void InsertProcessCommand(ProcessCommandEditDto dto) { if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); const string CommandText = @" INSERT INTO [dbo].[Commands] ( [ProcessId] ,[LastModifiedOn] ,[GuidId] ,[CommandName] ,[CommandType] ,[Documentation] ,[IntegrationServiceGuid] ,[DataTriggerGuid] ) VALUES ( @p_ProcessId ,@p_LastModifiedOn ,@p_GuidId ,@p_CommandName ,@p_CommandType ,@p_Documentation ,@p_IntegrationServiceGuid ,@p_DataTriggerGuid ); SELECT [Id] FROM [dbo].[Commands] WHERE [Id] = SCOPE_IDENTITY()"; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; using (var command = new SqlCommand(CommandText, connection)) { command.Parameters.AddWithValue("@p_ProcessId", dto.ProcessId); command.Parameters.AddWithValue("@p_LastModifiedOn", dto.LastModifiedOn); command.Parameters.AddWithValue("@p_GuidId", dto.GuidId); command.Parameters.AddWithValue("@p_CommandName", dto.CommandName); command.Parameters.AddWithValue("@p_CommandType", dto.CommandType); command.Parameters.AddWithValue("@p_Documentation", dto.Documentation); command.Parameters.AddWithValue("@p_IntegrationServiceGuid", AdoHelper.NullCheck(dto.IntegrationServiceGuid)); command.Parameters.AddWithValue("@p_DataTriggerGuid", AdoHelper.NullCheck(dto.DataTriggerGuid)); dto.Id = (int)command.ExecuteScalar(); } } }