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:
@@ -16,11 +16,11 @@ public static class DependencyInjection
|
||||
services.TryAddScoped<IProfileObjRepository, ProfileObjRepository>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ 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
|
||||
{
|
||||
@@ -21,21 +21,21 @@ public class ProfileObjRepository : 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 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 != null ? objState.State1 : null)
|
||||
.Include(obj => obj.States).ThenInclude(objState => objState != null ? objState.TFControls : null)
|
||||
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.State1 : null)
|
||||
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TFControls : null)
|
||||
.ToListAsync(cancel);
|
||||
}
|
||||
@@ -11,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; }
|
||||
|
||||
@@ -46,8 +46,8 @@ public class WFDBContext : DbContext, IUserManagerDbContext
|
||||
//configure model builder for user manager tables
|
||||
modelBuilder.ConfigureUserManager();
|
||||
|
||||
modelBuilder.Entity<ProfileObjState>()
|
||||
.HasMany(pos => pos.ControlsTF)
|
||||
modelBuilder.Entity<PObjectState>()
|
||||
.HasMany(pos => pos.TFControls)
|
||||
.WithOne()
|
||||
.HasForeignKey(pctf => pctf.ObjStateId)
|
||||
.HasPrincipalKey(pos => pos.Id)
|
||||
|
||||
Reference in New Issue
Block a user