Enhance state management in DTOs and entities

- Added `States` property to `ProfileObjStateDto` and `ObjectDto`.
- Updated `MappingProfile` to include new `States` mapping.
- Made `StateId` in `ProfileObjState` required and added `State1` navigation property.
- Changed `ProfileObject` to use `States` instead of `State`.
- Cleaned up `State` class structure and removed redundant namespaces.
- Updated `ProfileObjRepository` to fetch related state data.
This commit is contained in:
2025-08-01 02:50:19 +02:00
parent 7309b968fe
commit ad023b01d3
7 changed files with 36 additions and 43 deletions

View File

@@ -37,14 +37,9 @@ public class ProfileObjState
[Column("OBJ_ID", TypeName = "bigint")]
public long? ObjectId { 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("STATE_ID", TypeName = "int")]
public int? StateId { get; set; }
public int StateId { get; set; }
[Column("STATE2", TypeName = "nvarchar(100)")]
[StringLength(100)]
@@ -83,4 +78,13 @@ public class ProfileObjState
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[ForeignKey("StateId")]
public virtual State? State1 { get; set; }
[NotMapped]
public IEnumerable<string?> States => new List<string?>
{
State1?.IntlState, State2, State3, State4
};
}

View File

@@ -26,5 +26,5 @@ public class ProfileObject
public string? CmdCheckIn { get; set; }
[ForeignKey("ObjStateId")]
public virtual ProfileObjState? State { get; set; }
public virtual ProfileObjState? States { get; set; }
}

View File

@@ -1,25 +1,24 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace WorkFlow.Domain.Entities
namespace WorkFlow.Domain.Entities;
[Table("TBMWF_WF_STATE", Schema = "dbo")]
public class State
{
[Table("TBMWF_WF_STATE", Schema = "dbo")]
public class State
{
[Key]
[Column("GUID")]
public int Id { get; init; }
[Key]
[Column("GUID")]
public int Id { get; init; }
[Required]
[Column("INTL_STATE", TypeName = "varchar(100)")]
public required string IntlState { get; init; }
[Required]
[Column("INTL_STATE", TypeName = "varchar(100)")]
public required string IntlState { get; init; }
[Required]
[Column("ADDED_WHO", TypeName = "varchar(30)")]
public required string AddedWho { get; init; }
[Required]
[Column("ADDED_WHO", TypeName = "varchar(30)")]
public required string AddedWho { get; init; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public required DateTime AddedWhen { get; init; }
}
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public required DateTime AddedWhen { get; init; }
}