Compare commits

...

17 Commits

Author SHA1 Message Date
b859391ab1 feat: Beziehung zwischen „ObjectState“ und „TfFiles“ hinzufügen 2025-08-01 16:02:03 +02:00
26300d8653 feat(TfFile): Entität mit Metadaten und Schema-Zuordnung hinzufügen
- Enthält detaillierte Schema-Zuordnung mit Validierungshinweisen für nullfähige Felder.
- Ermöglicht die Verfolgung von Dateimetadaten innerhalb des Workflow-Systems.
2025-08-01 15:51:12 +02:00
9d07b1e71c refactor: Beziehung zwischen „Object“ und „History“ hinzufügen. 2025-08-01 15:08:30 +02:00
ec975a2bc3 Add StateHistory property to PObject class
Introduces a new `StateHistory` property in the `PObject` class within `PObject.cs`. This property is decorated with the `[ForeignKey("ObjStateId")]` attribute and is of type `IEnumerable<PObjectStateHist>?`, allowing it to store a collection of `PObjectStateHist` objects. It is initialized to an empty array using `Array.Empty<PObjectStateHist>()`.
2025-08-01 14:04:15 +02:00
f10f5af541 Add mapping for PObjectStateHist and new DTO record
Introduced a mapping configuration in `MappingProfile` to map `PObjectStateHist` to `ObjectStateHistDto`, including the `Intl` property and an array of `Others`. Added a new record `ObjectStateHistDto` with properties for `Intl`, `Others`, `ChangedWho`, and `ChangedWhen`, initializing `Others` to an empty array of strings.
2025-08-01 14:00:26 +02:00
7d07fc58e9 Remove ToList() method from PObjectStateHist class
The `ToList()` method in the `PObjectStateHist` class has been removed. This method previously returned a list of strings, including the `IntlState` property of `State1` and other state properties (`State2`, `State3`, `State4`). Its removal indicates that this functionality is no longer needed or has been refactored.
2025-08-01 13:48:27 +02:00
7e82f688ad Remove ToList() method from PObjectState class
The `ToList()` method in the `PObjectState` class has been removed. This method previously returned a list of strings, including the `IntlState` property of `State1` and other state properties (`State2`, `State3`, `State4`). Its removal indicates that this functionality is no longer needed or has been refactored.
2025-08-01 13:47:50 +02:00
c325b2122b Add PObjectStateHist class for state history tracking
Introduces the `PObjectStateHist` class in the `WorkFlow.Domain.Entities` namespace, mapped to the `TBMWF_PROFILE_OBJ_STATE_HISTORY` table. The class includes properties with data annotations for validation and schema mapping, addressing nullable fields treated as required in application logic. A `ToList()` method is added to return state-related strings, enhancing functionality.
2025-08-01 13:47:22 +02:00
63adb51263 Refactor ButtonDto and ReadButtonRequest
Removed unused MediatR directive, added required ProfileId
property, and removed DialogNo from ButtonDto. Updated
ReadButtonRequest to inherit from IRequest<ButtonDto>
for MediatR integration.
2025-08-01 13:27:06 +02:00
363606dc61 Refactor DTOs and mappings for improved structure
- Removed `Id`, `Headlines`, and `States` from `ObjectDto`; added `State` property of type `ObjectStateDto?`.
- Completely removed `ProfileControlsTFDto` and `StateDto` classes.
- Removed `Id` from `ProfileDto`, keeping `TypeId` unchanged.
- Updated `MappingProfile` to remove mappings for `ProfileControlsTFDto` and `StateDto`, and changed mapping for `PControlsTF` to `PControlsTFDto`.
- Introduced new `ObjectStateDto` class with properties for `Intl`, `Others`, and a collection of `TFControls`.
- Added new `PControlsTFDto` class with various control attributes.
2025-08-01 13:19:10 +02:00
bc192e99a7 Refactor ObjectDto and update PObjectState relationships
Removed ObjStateId and Id from ObjectDto for simplification.
Updated foreign key in PObjectState from ObjStateId to StateId,
and modified TFControls to support nullable collections.
Adjusted WFDBContext configuration for clearer foreign key
relationships and improved maintainability of the database schema.
2025-08-01 12:53:56 +02:00
69d417616d Refactor repository structure in WorkFlow.Infrastructure
Removed ProfileObjRepository and migrated its functionality to PObjectRepository. Updated DependencyInjection.cs to register the new repository for dependency injection, improving clarity and organization while maintaining existing functionality.
2025-08-01 12:04:06 +02:00
a3cbe69fd6 Refactor data model: rename entities and update mappings
This commit includes a significant refactoring of the data model, renaming `ProfileObject` to `PObject` and `ProfileControlsTF` to `PControlsTF`.

Key changes:
- Updated `IProfileObjRepository` to reflect new entity names.
- Added `TFControls` property to `ObjectDto`.
- Adjusted `MappingProfile` for new entity mappings.
- Replaced `ProfileControlsTF` and `ProfileObjState` with `PControlsTF` and `PObjectState`.
- Updated `WFDBContext` with new DbSet properties for the renamed entities.
- Modified `ProfileObjRepository` to align with the new data structure.

These changes enhance clarity and maintainability across the application.
2025-08-01 12:02:34 +02:00
c2e8b335e0 Refactor ProfileControlsTFDto and update ProfileControlsTF
The `ProfileControlsTFDto` class has been changed from a record type to a class with auto-implemented properties, enhancing its structure and usability. Several properties have been renamed or removed, and new properties like `DialogNo`, `Text`, and `Icon` have been added.

In the `ProfileControlsTF` class, the `Sequ` property has been updated to remove its default value assignment, maintaining its nullable byte type.
2025-08-01 11:10:24 +02:00
7ed86f18d7 Refactor ProfileControlsTF and ProfileObjState relationships
Updated property names and foreign key references in
ProfileControlsTF and ProfileObjState classes to improve
database relationship integrity. Added TFControls collection
to ProfileObjState and modified queries in ProfileObjRepository
to include related entities. Established relationships in
WFDBContext with cascade delete behavior.
2025-08-01 10:54:08 +02:00
2fd64cb616 Fix null reference issue in ReadAsync method
Updated the inclusion of the `States` property in the
`ReadAsync` method of `ProfileObjRepository` to check
for null values before accessing `State1`. This change
prevents potential null reference exceptions.
2025-08-01 10:07:30 +02:00
b89a69b0f3 Remove ProfileObjStateDto and update mappings
- Deleted the `ProfileObjStateDto` class and its `States` property.
- Removed mapping for `ProfileObjState` to `ProfileObjStateDto` in `MappingProfile`.
- Updated `States` mapping to handle null values by converting to a list or returning an empty array.
- Replaced `States` property in `ProfileObjState` with a `ToList()` method that aggregates state values.
2025-08-01 09:41:16 +02:00
20 changed files with 243 additions and 94 deletions

View File

@@ -1,13 +1,7 @@
using MediatR;
namespace WorkFlow.Application.Buttons;
namespace WorkFlow.Application.Buttons;
public record ButtonDto
{
public int Id { get; init; }
public required int ProfileId { get; init; }
public byte? DialogNo { get; init; }
public string? BtnType { get; init; }
@@ -23,6 +17,4 @@ public record ButtonDto
public string? DialogCommand { get; init; }
public string? ConfirmationText { get; init; }
}
public record ReadButtonRequest : IRequest<ButtonDto>;
}

View File

@@ -3,21 +3,21 @@
namespace WorkFlow.Application.Contracts.Repositories;
/// <summary>
/// Repository for retrieving <see cref="ProfileObject"/> entities from the database.
/// Repository for retrieving <see cref="PObject"/> entities from the database.
/// </summary>
public interface IProfileObjRepository
{
/// <summary>
/// Retrieves the list of <see cref="ProfileObject"/> associated with a given user ID and profile ID by calling a database function.
/// Retrieves the list of <see cref="PObject"/> associated with a given user ID and profile ID by calling a database function.
/// </summary>
/// <param name="userId">The unique identifier of the user whose profile is to be retrieved.</param>
/// <param name="profileId">The unique identifier of the profile whose object is to be retrieved.</param>
/// <param name="cancel">Propagates notification that operations should be canceled.</param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the <see cref="ProfileObject"/> object if found; otherwise, <c>null</c>.
/// A task that represents the asynchronous operation. The task result contains the <see cref="PObject"/> object if found; otherwise, <c>null</c>.
/// </returns>
/// <remarks>
/// Logs an error if no profile is found, or if multiple profiles are returned, indicating potential data issues.
/// </remarks>
public Task<IEnumerable<ProfileObject>> ReadAsync(int userId, int profileId, CancellationToken cancel = default);
public Task<IEnumerable<PObject>> ReadAsync(int userId, int profileId, CancellationToken cancel = default);
}

View File

@@ -2,15 +2,13 @@
public class ObjectDto
{
public long? ObjStateId { get; set; }
public long? Id { get; set; }
public IEnumerable<string> Headlines { get; set; } = Array.Empty<string>();
public IEnumerable<string> Sublines { get; set; } = Array.Empty<string>();
public string? CmdCheckIn { get; set; }
public IEnumerable<string?> States { get; set; } = Array.Empty<string>();
public ObjectStateDto? State { get; set; }
public IEnumerable<ObjectStateHistDto> StateHistories { get; set; } = Array.Empty<ObjectStateHistDto>();
}

View File

@@ -0,0 +1,13 @@
namespace WorkFlow.Application.Dto;
public record ObjectStateDto
{
public virtual string? Intl { get; set; }
/// <summary>
/// Holds state 2, 3 and 4 as a list of strings.
/// </summary>
public IEnumerable<string> Others { get; set; } = Array.Empty<string>();
public virtual IEnumerable<PControlsTFDto>? TFControls { get; set; }
}

View File

@@ -0,0 +1,15 @@
namespace WorkFlow.Application.Dto;
public record ObjectStateHistDto
{
public virtual string? Intl { get; set; }
/// <summary>
/// Holds state 2, 3 and 4 as a list of strings.
/// </summary>
public IEnumerable<string> Others { get; set; } = Array.Empty<string>();
public string? ChangedWho { get; set; }
public DateTime? ChangedWhen { get; set; }
}

View File

@@ -0,0 +1,24 @@
namespace WorkFlow.Application.Dto;
public record PControlsTFDto
{
public byte? DialogNo { get; set; }
public string? AttrName { get; set; }
public string? CtrlType { get; set; }
public string? Caption { get; set; }
public string? Text { get; set; }
public string? Icon { get; set; }
public bool? Mandatory { get; set; }
public string? ChoiceList { get; set; }
public bool? ReadOnly { get; set; }
public byte? Sequ { get; set; }
}

View File

@@ -1,19 +0,0 @@
using DigitalData.UserManager.Application.DTOs.User;
namespace WorkFlow.Application.Dto
{
public record ProfileControlsTFDto(int Id,
int ProfileId,
int UserId,
long ObjId,
string ObjType,
string AttrName,
string CtrlType,
string CtrlCaption,
bool Mandatory,
bool ReadOnly,
string AddedWho,
DateTime AddedWhen,
string? ChoiceList = null,
UserReadDto? User = null);
}

View File

@@ -4,8 +4,6 @@ namespace WorkFlow.Application.Dto;
public class ProfileDto
{
public int? Id { get; init; }
public byte? TypeId { get; init; }
public string? Caption { get; init; }

View File

@@ -1,6 +0,0 @@
namespace WorkFlow.Application.Dto;
public class ProfileObjStateDto
{
public IEnumerable<string?> States { get; set; } = Array.Empty<string>();
}

View File

@@ -1,4 +0,0 @@
namespace WorkFlow.Application.Dto
{
public record StateDto(int Id, string IntlState, string AddedWho, DateTime AddedWhen);
}

View File

@@ -11,15 +11,16 @@ public class MappingProfile : AutoMapper.Profile
// Mapping entity to DTO
CreateMap<Config, ConfigDto>();
CreateMap<Profile, ProfileDto>();
CreateMap<ProfileControlsTF, ProfileControlsTFDto>();
CreateMap<ProfileObjState, ProfileObjStateDto>();
CreateMap<State, StateDto>();
CreateMap<PControlsTF, PControlsTFDto>();
CreateMap<Button, ButtonDto>();
CreateMap<ProfileObject, ObjectDto>()
.ForMember(dest => dest.Headlines, opt => opt.MapFrom(src =>
new[] { src.Headline1, src.Headline2 }))
.ForMember(dest => dest.Sublines, opt => opt.MapFrom(src =>
new[] { src.Subline1, src.Subline2 }))
.ForMember(dest => dest.States, opt => opt.MapFrom(src => src.States));
CreateMap<PObject, ObjectDto>()
.ForMember(dest => dest.Headlines, opt => opt.MapFrom(src => new[] { src.Headline1, src.Headline2 }))
.ForMember(dest => dest.Sublines, opt => opt.MapFrom(src => new[] { src.Subline1, src.Subline2 }));
CreateMap<PObjectState, ObjectStateDto>()
.ForMember(dest => dest.Intl, opt => opt.MapFrom(src => src.State1 != null ? src.State1.IntlState : null))
.ForMember(dest => dest.Others, opt => opt.MapFrom(src => new string?[] { src.State2, src.State3, src.State4 }));
CreateMap<PObjectStateHist, ObjectStateHistDto>()
.ForMember(dest => dest.Intl, opt => opt.MapFrom(src => src.State1 != null ? src.State1.IntlState : null))
.ForMember(dest => dest.Others, opt => opt.MapFrom(src => new string?[] { src.State2, src.State3, src.State4 }));
}
}

View File

@@ -4,20 +4,15 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace WorkFlow.Domain.Entities;
[Table("TBMWF_PROF_CONTROLS_TF", Schema = "dbo")]
public class ProfileControlsTF
public class PControlsTF
{
[Key]
[Column("GUID", TypeName = "bigint")]
public long Id { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Required]
[Column("OBJ_STATE_ID", TypeName = "bigint")]
public long? StateId { get; set; }
public long ObjStateId { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
@@ -89,14 +84,11 @@ public class ProfileControlsTF
public bool? ReadOnly { get; set; }
[Column("SEQU", TypeName = "tinyint")]
public byte? Sequ { get; set; } = 0;
public byte? Sequ { get; set; }
[Column("ADDED_WHO", TypeName = "nvarchar(100)")]
public required string AddedWho { get; set; }
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[ForeignKey("StateId")]
public virtual ProfileObjState? State { get; set; }
}

View File

@@ -2,7 +2,7 @@
namespace WorkFlow.Domain.Entities;
public class ProfileObject
public class PObject
{
[Column("ObjStateID")]
public long? ObjStateId { get; set; }
@@ -26,5 +26,7 @@ public class ProfileObject
public string? CmdCheckIn { get; set; }
[ForeignKey("ObjStateId")]
public virtual ProfileObjState? States { get; set; }
public virtual PObjectState? State { get; set; }
public virtual IEnumerable<PObjectStateHist>? StateHistories { get; set; }
}

View File

@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace WorkFlow.Domain.Entities;
[Table("TBMWF_PROFILE_OBJ_STATE", Schema = "dbo")]
public class ProfileObjState
public class PObjectState
{
[Key]
[Column("GUID", TypeName = "bigint")]
@@ -82,9 +82,7 @@ public class ProfileObjState
[ForeignKey("StateId")]
public virtual State? State1 { get; set; }
[NotMapped]
public IEnumerable<string?> States => new List<string?>
{
State1?.IntlState, State2, State3, State4
};
public virtual IEnumerable<PControlsTF>? TFControls { get; set; }
public virtual IEnumerable<TfFile>? TfFiles { get; set; }
}

View File

@@ -0,0 +1,65 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace WorkFlow.Domain.Entities;
[Table("TBMWF_PROFILE_OBJ_STATE_HISTORY", Schema = "dbo")]
public class PObjectStateHist
{
[Key]
[Column("GUID", TypeName = "bigint")]
public long Id { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("MWF_PROFILE_ID", TypeName = "int")]
public int? ProfileId { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("USR_ID", TypeName = "int")]
public int? UserId { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("OBJ_ID", TypeName = "bigint")]
public long? ObjectId { get; set; }
[Required]
[Column("STATE_ID", TypeName = "int")]
public int StateId { get; set; }
[Column("STATE2", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State2 { get; set; }
[Column("STATE3", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State3 { get; set; }
[Column("STATE4", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? State4 { get; set; }
[Column("CHANGED_WHO", TypeName = "nvarchar(100)")]
[StringLength(100)]
public string? ChangedWho { get; set; }
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[ForeignKey("StateId")]
public virtual State? State1 { get; set; }
}

View File

@@ -26,7 +26,7 @@ public class Profile
public string? BackColor { get; set; }
[NotMapped]
public IEnumerable<ProfileObject>? Objects { get; set; }
public IEnumerable<PObject>? Objects { get; set; }
[NotMapped]
public IEnumerable<Button>? Buttons { get; set; }

View File

@@ -0,0 +1,60 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace WorkFlow.Domain.Entities;
[Table("TBMWF_TF_FILES")]
public class TfFile
{
[Key]
[Column("GUID", TypeName = "bigint")]
public long Id { get; set; }
[Required]
[Column("OBJ_STATE_ID", TypeName = "bigint")]
public long ObjStateId { get; set; }
[Required]
[StringLength(512)]
[Column("F_FAPTH", TypeName = "nvarchar(512)")]
public string FFapth { get; set; } = null!;
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("HEADLINE", TypeName = "nvarchar(100)")]
public string? Headline { get; set; }
[StringLength(100)]
[Column("SUBLINE", TypeName = "nvarchar(100)")]
public string? Subline { get; set; }
[StringLength(250)]
[Column("COMMENT", TypeName = "nvarchar(250)")]
public string? Comment { get; set; }
[StringLength(100)]
[Column("ICON", TypeName = "nvarchar(100)")]
public string? Icon { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("ADDED_WHO", TypeName = "nvarchar(100)")]
public string? AddedWho { get; set; }
/// <summary>
/// Although this field is marked as <c>nullable</c> in the database schema to allow
/// for greater flexibility during database-level operations or migrations, it is
/// treated as <c>required</c> and <c>not null</c> within the application logic.
/// Validation should be enforced at the application level to ensure a value is provided.
/// </summary>
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime? AddedWhen { get; set; }
}

View File

@@ -13,14 +13,14 @@ public static class DependencyInjection
public static IServiceCollection AddWorkFlowRepositories(this IServiceCollection services)
{
services.TryAddScoped<IProfileRepository, ProfileRepository>();
services.TryAddScoped<IProfileObjRepository, ProfileObjRepository>();
services.TryAddScoped<IProfileObjRepository, PObjectRepository>();
services.AddDbRepository<WFDBContext, Config>(c => c.Configs).UseAutoMapper();
services.AddDbRepository<WFDBContext, ProfileControlsTF>(c => c.ProfileControlsTFs).UseAutoMapper();
services.AddDbRepository<WFDBContext, PControlsTF>(c => c.ProfileControlsTFs).UseAutoMapper();
services.AddDbRepository<WFDBContext, State>(c => c.States).UseAutoMapper();
services.AddDbRepository<WFDBContext, Button>(c => c.Buttons).UseAutoMapper();
services.AddDbRepository<WFDBContext, State>(c => c.States).UseAutoMapper();
services.AddDbRepository<WFDBContext, ProfileObjState>(c => c.ProfileObjStates).UseAutoMapper();
services.AddDbRepository<WFDBContext, PObjectState>(c => c.ProfileObjStates).UseAutoMapper();
return services;
}

View File

@@ -5,36 +5,39 @@ using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure.Repositories;
/// <summary>
/// Repository implementation for retrieving <see cref="ProfileObject"/> entities from the database.
/// Repository implementation for retrieving <see cref="PObject"/> entities from the database.
/// </summary>
public class ProfileObjRepository : IProfileObjRepository
public class PObjectRepository : IProfileObjRepository
{
private readonly WFDBContext _context;
/// <summary>
/// Initializes a new instance of the <see cref="ProfileObjRepository"/> class.
/// Initializes a new instance of the <see cref="PObjectRepository"/> class.
/// </summary>
/// <param name="context">The database context used for accessing profile data.</param>
public ProfileObjRepository(WFDBContext context)
public PObjectRepository(WFDBContext context)
{
_context = context;
}
/// <summary>
/// Retrieves the list of <see cref="ProfileObject"/> associated with a given user ID and profile ID by calling a database function.
/// Retrieves the list of <see cref="PObject"/> associated with a given user ID and profile ID by calling a database function.
/// </summary>
/// <param name="userId">The unique identifier of the user whose profile is to be retrieved.</param>
/// <param name="profileId">The unique identifier of the profile whose object is to be retrieved.</param>
/// <param name="cancel">Propagates notification that operations should be canceled.</param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the <see cref="ProfileObject"/> object if found; otherwise, <c>null</c>.
/// A task that represents the asynchronous operation. The task result contains the <see cref="PObject"/> object if found; otherwise, <c>null</c>.
/// </returns>
/// <remarks>
/// Logs an error if no profile is found, or if multiple profiles are returned, indicating potential data issues.
/// </remarks>
public async Task<IEnumerable<ProfileObject>> ReadAsync(int userId, int profileId, CancellationToken cancel = default)
public async Task<IEnumerable<PObject>> ReadAsync(int userId, int profileId, CancellationToken cancel = default)
=> await _context.Objects
.FromSqlRaw("SELECT * FROM [FNMWF_GET_PROFILE_OBJECTS] ({0}, {1})", userId, profileId)
.Include(obj => obj.States).ThenInclude(objState => objState.State1)
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.State1 : null)
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TFControls : null)
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TfFiles : null)
.Include(obj => obj.StateHistories!).ThenInclude(hist => hist != null ? hist.State1 : null)
.ToListAsync(cancel);
}

View File

@@ -2,6 +2,7 @@
using DigitalData.UserManager.Infrastructure;
using DigitalData.UserManager.Infrastructure.Contracts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.SqlServer.Query.Internal;
using WorkFlow.Domain.Entities;
namespace WorkFlow.Infrastructure;
@@ -10,13 +11,13 @@ public class WFDBContext : DbContext, IUserManagerDbContext
{
public DbSet<Config> Configs { get; set; }
public DbSet<ProfileControlsTF> ProfileControlsTFs { get; set; }
public DbSet<PControlsTF> ProfileControlsTFs { get; set; }
public DbSet<Profile> Profiles { get; set; }
public DbSet<ProfileObject> Objects { get; set; }
public DbSet<PObject> Objects { get; set; }
public DbSet<ProfileObjState> ProfileObjStates { get; set; }
public DbSet<PObjectState> ProfileObjStates { get; set; }
public DbSet<State> States { get; set; }
@@ -45,6 +46,22 @@ public class WFDBContext : DbContext, IUserManagerDbContext
//configure model builder for user manager tables
modelBuilder.ConfigureUserManager();
modelBuilder.Entity<PObjectState>()
.HasMany(objState => objState.TFControls)
.WithOne()
.HasForeignKey(control => control.ObjStateId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<PObjectState>()
.HasMany(objState => objState.TfFiles)
.WithOne()
.HasForeignKey(file => file.ObjStateId);
modelBuilder.Entity<PObject>()
.HasMany(p => p.StateHistories)
.WithOne()
.HasForeignKey(hist => hist.ObjectId);
base.OnModelCreating(modelBuilder);
}
}