rama creada apartir de master en j
This commit is contained in:
@@ -9,13 +9,21 @@ using MongoDB.Driver;
|
||||
|
||||
namespace adas_core.Infrastructure.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// Repository implementation for managing CardDetailsConfig entities in MongoDB.
|
||||
/// Provides CRUD operations for display detail configurations used in nurse and smart displays.
|
||||
/// </summary>
|
||||
public class DisplayDetailConfigRepository : MongoRepository<CardDetailsConfig>, IDisplayDetailConfigRepository
|
||||
{
|
||||
private readonly ApiSettings _apiSettings;
|
||||
private readonly ILogger<DisplayDetailConfigRepository> _logger;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DisplayDetailConfigRepository.
|
||||
/// </summary>
|
||||
/// <param name="database">The MongoDB database instance.</param>
|
||||
/// <param name="apiSettings">API settings containing collection names configuration.</param>
|
||||
/// <param name="logger">Logger for repository operations.</param>
|
||||
public DisplayDetailConfigRepository(
|
||||
IMongoDatabase database,
|
||||
ApiSettings apiSettings,
|
||||
@@ -26,17 +34,31 @@ public class DisplayDetailConfigRepository : MongoRepository<CardDetailsConfig>,
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the collection for display detail configurations.
|
||||
/// </summary>
|
||||
/// <returns>The collection name from API settings.</returns>
|
||||
public override string GetCollectionName()
|
||||
{
|
||||
return _apiSettings.DisplayDetailConfig;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all display detail configurations from the database.
|
||||
/// </summary>
|
||||
/// <returns>A list of all CardDetailsConfig entities.</returns>
|
||||
public async Task<List<CardDetailsConfig>> GetAll()
|
||||
{
|
||||
var result = await Collection.Find(Builders<CardDetailsConfig>.Filter.Empty).ToListAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a display detail configuration by its ID.
|
||||
/// </summary>
|
||||
/// <param name="configId">The ObjectId of the detail configuration to retrieve.</param>
|
||||
/// <returns>The CardDetailsConfig if found; otherwise, null.</returns>
|
||||
/// <exception cref="Exception">Throws an exception if MongoDB query fails; returns null instead.</exception>
|
||||
public async Task<CardDetailsConfig?> GetById(ObjectId configId)
|
||||
{
|
||||
try
|
||||
@@ -51,6 +73,11 @@ public class DisplayDetailConfigRepository : MongoRepository<CardDetailsConfig>,
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Inserts a new display detail configuration and returns the inserted document.
|
||||
/// </summary>
|
||||
/// <param name="config">The CardDetailsConfig to insert.</param>
|
||||
/// <returns>The inserted CardDetailsConfig, or null if insertion fails.</returns>
|
||||
public async Task<CardDetailsConfig?> InsertOneAsyncAndReturn(CardDetailsConfig config)
|
||||
{
|
||||
try
|
||||
@@ -65,6 +92,12 @@ public class DisplayDetailConfigRepository : MongoRepository<CardDetailsConfig>,
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing display detail configuration with new values.
|
||||
/// </summary>
|
||||
/// <param name="config">The CardDetailsConfig with updated values.</param>
|
||||
/// <returns>An UpdateResponse containing the modified count and the updated document.</returns>
|
||||
/// <exception cref="Exception">Throws an exception if MongoDB update fails; returns UpdateResponse with null document.</exception>
|
||||
public async Task<UpdateResponse<CardDetailsConfig?>> UpdateOne(CardDetailsConfig? config)
|
||||
{
|
||||
try
|
||||
@@ -92,11 +125,23 @@ public class DisplayDetailConfigRepository : MongoRepository<CardDetailsConfig>,
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a display detail configuration by its ID.
|
||||
/// </summary>
|
||||
/// <param name="configId">The ObjectId of the configuration to delete.</param>
|
||||
/// <returns>The deleted CardDetailsConfig if found; otherwise, null.</returns>
|
||||
public async Task<CardDetailsConfig?> DeleteOne(ObjectId configId)
|
||||
{
|
||||
return await DeleteAsync(configId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the display configuration ID reference. This method is not implemented.
|
||||
/// </summary>
|
||||
/// <param name="displayConfigId">The ObjectId of the display configuration.</param>
|
||||
/// <param name="resultId">The new reference ID to set.</param>
|
||||
/// <returns>Always throws NotImplementedException.</returns>
|
||||
/// <exception cref="NotImplementedException">This method is not implemented.</exception>
|
||||
public Task<object> UpdateCardConfigId(ObjectId? displayConfigId, ObjectId? resultId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
Reference in New Issue
Block a user