Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Inserts documentation step.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">Indicates stale data.</exception>
        /// <exception cref="System.Data.DBConcurrencyException">Indicates stale data.</exception>
        public void InsertDocumentationStep(DocumentationStepDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
            {
                var connection = ctx.Connection;

                const string CommandText =
                    @"
    INSERT INTO [dbo].[DocumentationFieldStep]
           ([Prompt]
           ,[FieldId]
           ,[Documentation]
           ,[UseRichText])
     VALUES
           (@p_Prompt,
           @p_FieldId,
           @p_Documentation,
           @p_UseRichText)
    SET @p_id = SCOPE_IDENTITY()";

                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_Prompt", dto.Prompt);
                    command.Parameters.AddWithValue("@p_FieldId", dto.FieldId);
                    command.Parameters.AddWithValue("@p_Documentation", dto.Documentation);
                    command.Parameters.AddWithValue("@p_UseRichText", dto.UseRichText);
                    command.Parameters.AddWithValue("@p_LastModifiedOn", DateTime.Now);
                    var idParam = new SqlParameter("@p_id", SqlDbType.Int, 0, "Id") { Direction = ParameterDirection.Output };
                    command.Parameters.Add(idParam);

                    var rowsAffetcted = command.ExecuteNonQuery();
                    if (rowsAffetcted == 0)
                    {
                        throw new DBConcurrencyException(Resources.StaleDataException);
                    }

                    dto.Id = (int)idParam.Value;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates documentation step.
        /// </summary>
        /// <param name="buildDto">The build DTO.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void UpdateDocumentationStep(DocumentationStepDto buildDto)
        {
            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 = @"
IF EXISTS ( SELECT * FROM [dbo].[DocumentationFieldStep] WHERE Id = @p_id)
    UPDATE [dbo].[DocumentationFieldStep]
    SET Prompt = @p_Prompt, Documentation = @p_Documentation, UseRichText = @p_UseRichText, LastUpdatedOn = @p_LastModifiedOn
    WHERE id = @p_id
ELSE
BEGIN
    SET IDENTITY_INSERT dbo.DocumentationFieldStep ON
    INSERT dbo.DocumentationFieldStep ( Id, Prompt, FieldId, Documentation, UseRichText )
    VALUES  ( @p_id, @p_Prompt, @p_fieldId, @p_Documentation, @p_UseRichText )
    SET IDENTITY_INSERT dbo.DocumentationFieldStep OFF
END";
                using (var command = new SqlCommand(CommandText, connection))
                {
                    command.Parameters.AddWithValue("@p_id", buildDto.Id);
                    command.Parameters.AddWithValue("@p_fieldId", buildDto.FieldId);
                    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();
                }
            }
        }