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.
This commit is contained in:
2025-08-01 12:02:34 +02:00
parent c2e8b335e0
commit a3cbe69fd6
10 changed files with 33 additions and 40 deletions

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

@@ -13,4 +13,6 @@ public class ObjectDto
public string? CmdCheckIn { get; set; }
public IEnumerable<string?> States { get; set; } = Array.Empty<string>();
public IEnumerable<ProfileControlsTFDto> TFControls { get; set; } = Array.Empty<ProfileControlsTFDto>();
}

View File

@@ -11,14 +11,13 @@ public class MappingProfile : AutoMapper.Profile
// Mapping entity to DTO
CreateMap<Config, ConfigDto>();
CreateMap<Profile, ProfileDto>();
CreateMap<ProfileControlsTF, ProfileControlsTFDto>();
CreateMap<PControlsTF, ProfileControlsTFDto>();
CreateMap<State, StateDto>();
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 != null ? src.States.ToList() : Array.Empty<string>()));
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 }))
.ForMember(dest => dest.States, opt => opt.MapFrom(src => src.State != null ? src.State.ToList() : Array.Empty<string>()))
.ForMember(dest => dest.TFControls, opt => opt.MapFrom(src => src.State != null ? src.State.TFControls : null));
}
}