示例#1
0
        /// <summary>
        /// Updates process view section.
        /// </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 UpdateProcessViewSectionWithLocalization(ProcessViewSectionEditDto dto, ProcessViewSectionLocalizationDto locDto)
        {
            if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
    @"
UPDATE [dbo].[ProcessViewSections]
SET  [Guid]                       = @p_Guid
    ,[TemplateSectionGuid]        = @p_TemplateSectionGuid
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_Guid", dto.Guid);
                    command.Parameters.AddWithValue("@p_TemplateSectionGuid", dto.TemplateSectionGuid);

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

            UpdateProcessViewSectionLocalization(locDto);
        }
示例#2
0
        /// <summary>
        /// Inserts process view section.
        /// </summary>
        /// <param name="dto">The DTO object.</param>
        /// <exception cref="System.ArgumentNullException">The input DTO is null.</exception>
        public void InsertProcessViewSection(ProcessViewSectionEditDto dto)
        {
            if (dto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "dto"));

            const string CommandText =
    @"
INSERT INTO [dbo].[ProcessViewSections]
(
     [ProcessViewId]
    ,[Guid]
    ,[TemplateSectionGuid]
    ,[Name]
)
VALUES
(
     @p_ProcessViewId
    ,@p_Guid
    ,@p_TemplateSectionGuid
    ,@p_Name
);
SELECT [Id]
FROM [dbo].[ProcessViewSections]
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_ProcessViewId", dto.ProcessViewId);
                    command.Parameters.AddWithValue("@p_Guid", dto.Guid);
                    command.Parameters.AddWithValue("@p_TemplateSectionGuid", dto.TemplateSectionGuid);
                    command.Parameters.AddWithValue("@p_Name", dto.Name);

                    dto.Id = (int)command.ExecuteScalar();
                }
            }
        }