30 lines
1.4 KiB
C#
30 lines
1.4 KiB
C#
using adas_core.Application.Exceptions;
|
|
using adas_core.Application.Repositories.Interfaces;
|
|
using adas_core.Application.Services.Interfaces;
|
|
using adas_core.Domain.Enums;
|
|
using adas_core.Domain.Models.MongoModels;
|
|
using MongoDB.Bson;
|
|
|
|
namespace adas_core.Application.Services;
|
|
|
|
/// <summary>
|
|
/// Provides an implementation of the IAlertValuesService interface for managing alert values
|
|
/// using a configuration observation repository.
|
|
/// </summary>
|
|
/// <!-- aidoc:v1 sig=9cef6b0 -->
|
|
public class AlertValuesService(IConfigObservationRepository alertValueRepository) : IAlertValuesService
|
|
{
|
|
/// <summary>
|
|
/// Retrieves a <see cref="ConfigObservation"/> by its unique identifier from the alert value repository.
|
|
/// Throws a <see cref="NotFoundException"/> when no matching resource is found.
|
|
/// </summary>
|
|
/// <param name="key">The unique identifier of the configuration observation to retrieve.</param>
|
|
/// <returns>The matching <see cref="ConfigObservation"/> if found.</returns>
|
|
/// <exception cref="NotFoundException">Thrown when no configuration observation exists for the specified <paramref name="key"/>.</exception>
|
|
/// <!-- aidoc:v1 sig=2645546 body=5ae5bf7 -->
|
|
public async Task<ConfigObservation?> FindByKey(ObjectId key)
|
|
{
|
|
return await alertValueRepository.FindById(key) ??
|
|
throw new NotFoundException(HttpEnum.ErrorMessage.NotFoundResourceMissing);
|
|
}
|
|
} |