/// <summary> /// Updates display list required step. /// </summary> /// <param name="buildDto">The build DTO.</param> /// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.Data.DBConcurrencyException">Indicates stale data.</exception> /// <exception cref="System.ArgumentException">The input DTO is null.</exception> public void UpdateDisplayListRequiredStep(DisplayListRequiredStepDto buildDto) { if (buildDto == null) throw new ArgumentNullException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "buildDto")); const string CmdText = @" UPDATE [dbo].[DisplayListRequredFieldStep] SET [CrossRefProcessId] = @crossRefProcessId ,[FieldId] = @fieldId ,[DisplayFieldName] = @displayFieldName ,[IsOwner] = @isOwner ,[AllowRecentVersion] = @allowRecentVersion ,[FilterGuid] = @filterGuid ,[FilterDefinition] = @filterDef ,[IsSingleItemView] = @isSingleItemView WHERE [Id] = @stepId"; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var cn = ctx.Connection; using (var cmd = new SqlCommand(CmdText, cn)) { cmd.Parameters.AddWithValue("@stepId", buildDto.Id); cmd.Parameters.AddWithValue("@crossRefProcessId", AdoHelper.NullCheck(buildDto.CrossRefProcessId)); cmd.Parameters.AddWithValue("@fieldId", buildDto.FieldId); cmd.Parameters.AddWithValue("@displayFieldName", AdoHelper.NullCheck(buildDto.DisplayFieldName)); cmd.Parameters.AddWithValue("@isOwner", buildDto.IsOwner); cmd.Parameters.AddWithValue("@allowRecentVersion", buildDto.AllowRecentVersion); cmd.Parameters.AddWithValue("@filterGuid", AdoHelper.NullCheck(buildDto.FilterGuid)); cmd.Parameters.AddWithValue("@filterDef", AdoHelper.NullCheck(buildDto.FilterDefinition)); cmd.Parameters.AddWithValue("@isSingleItemView", buildDto.IsSingleItemView); var rowsAffetcted = cmd.ExecuteNonQuery(); if (rowsAffetcted == 0) { throw new DBConcurrencyException(Resources.StaleDataException); } } } }
/// <summary> /// Inserts display list required step. /// </summary> /// <param name="dto">The DTO object.</param> /// <exception cref="System.ArgumentException">Cross-reference process id is 0 /// or /// Cross-reference field id is 0.</exception> /// <exception cref="ArgumentException">Cross-reference process id is 0 /// or /// Cross-reference field id is 0.</exception> public void InsertDisplayListRequiredStep(DisplayListRequiredStepDto dto) { if (dto == null) throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.NullArguementException, "childData")); if (dto.CrossRefProcessId == 0 || dto.FieldId == 0) { if (dto.CrossRefProcessId == 0) { throw new ArgumentException("Cross-reference process id is 0"); } throw new ArgumentException("Cross-reference field id is 0"); } const string CmdText = @" INSERT INTO [dbo].[DisplayListRequredFieldStep] ( [CrossRefProcessId] ,[FieldId] ,[DisplayFieldName] ,[IsOwner] ,[AllowRecentVersion] ,[FilterGuid] ,[FilterDefinition] ,[IsSingleItemView] ) VALUES ( @crossRefProcessId ,@fieldId ,@displayFieldName ,@isOwner ,@allowRecentVersion ,@filterGuid ,@filterDef ,@isSingleItemView ); SELECT [Id] FROM [dbo].[DisplayListRequredFieldStep] WHERE [Id] = SCOPE_IDENTITY()"; using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false)) { var cn = ctx.Connection; using (var cmd = new SqlCommand(CmdText, cn)) { cmd.Parameters.AddWithValue("@crossRefProcessId", AdoHelper.NullCheck(dto.CrossRefProcessId)); cmd.Parameters.AddWithValue("@fieldId", dto.FieldId); cmd.Parameters.AddWithValue("@displayFieldName", AdoHelper.NullCheck(dto.DisplayFieldName)); cmd.Parameters.AddWithValue("@isOwner", dto.IsOwner); cmd.Parameters.AddWithValue("@allowRecentVersion", dto.AllowRecentVersion); cmd.Parameters.AddWithValue("@filterGuid", AdoHelper.NullCheck(dto.FilterGuid)); cmd.Parameters.AddWithValue("@filterDef", AdoHelper.NullCheck(dto.FilterDefinition)); cmd.Parameters.AddWithValue("@isSingleItemView", dto.IsSingleItemView); dto.Id = (int)cmd.ExecuteScalar(); } } }