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;
///
/// Provides an implementation of the IAlertValuesService interface for managing alert values
/// using a configuration observation repository.
///
public class AlertValuesService(IConfigObservationRepository alertValueRepository) : IAlertValuesService
{
///
/// Retrieves a by its unique identifier from the alert value repository.
/// Throws a when no matching resource is found.
///
/// The unique identifier of the configuration observation to retrieve.
/// The matching if found.
/// Thrown when no configuration observation exists for the specified .
public async Task FindByKey(ObjectId key)
{
return await alertValueRepository.FindById(key) ??
throw new NotFoundException(HttpEnum.ErrorMessage.NotFoundResourceMissing);
}
}