/// <summary> /// Updates documentation step. /// </summary> /// <param name="buildDto">The build DTO.</param> /// <param name="locDto">The localization DTO.</param> /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception> public void UpdateDocumentationStepWithLocaliztion(DocumentationStepDto buildDto, DocumentationStepLocalizationDto locDto) { if (buildDto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "buildDto")); // using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) // { // var connection = ctx.Connection; // const string CommandText = @" // UPDATE [dbo].[DocumentationFieldStep] // SET Prompt = @p_Prompt, Documentation = @p_Documentation, UseRichText = @p_UseRichText, LastUpdatedOn = @p_LastModifiedOn // WHERE id = @p_id"; // using (var command = new SqlCommand(CommandText, connection)) // { // command.Parameters.AddWithValue("@p_id", buildDto.Id); // command.Parameters.AddWithValue("@p_Prompt", buildDto.Prompt); // command.Parameters.AddWithValue("@p_Documentation", buildDto.Documentation); // command.Parameters.AddWithValue("@p_UseRichText", buildDto.UseRichText); // command.Parameters.AddWithValue("@p_LastModifiedOn", DateTime.Now); // command.ExecuteNonQuery(); // } // } UpdateDocumentationStepLocalization(locDto); }
/// <summary> /// Updates the localization for field documentation. /// </summary> /// <param name="dto">The localization dto.</param> /// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.Data.DBConcurrencyException"></exception> public void UpdateDocumentationStepLocalization(DocumentationStepLocalizationDto dto) { if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto")); using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var connection = ctx.Connection; const string commandText = @" IF EXISTS ( SELECT * FROM [dbo].[DocumentationFieldStepLocalizations] WHERE [LocalizationId] = @p_localizationId and [DocumentationFieldStepId] = @p_documentationFieldStepId) BEGIN UPDATE [dbo].[DocumentationFieldStepLocalizations] SET [LocalizationId] = @p_localizationId, [DocumentationFieldStepId] = @p_documentationFieldStepId, [GuidId] = @p_guidId, [Documentation] = @p_documentation, [Prompt] = @p_prompt WHERE [LocalizationId] = @p_localizationId and [DocumentationFieldStepId] = @p_documentationFieldStepId END ELSE INSERT INTO [dbo].[DocumentationFieldStepLocalizations] ( [LocalizationId], [DocumentationFieldStepId], [Documentation], [Prompt] ) VALUES ( @p_localizationId, @p_documentationFieldStepId, @p_documentation, @p_prompt)"; using (var command = new SqlCommand(commandText, connection)) { command.Parameters.AddWithValue("@p_localizationId", dto.LocalizationId); command.Parameters.AddWithValue("@p_documentationFieldStepId", dto.DocumentationFieldStepId); command.Parameters.AddWithValue("@p_guidId", dto.GuidId); command.Parameters.AddWithValue("@p_documentation", dto.Documentation); command.Parameters.AddWithValue("@p_prompt", dto.Prompt); var rowsAffetcted = command.ExecuteNonQuery(); if (rowsAffetcted == 0) { throw new DBConcurrencyException(Resources.StaleDataException); } } } }