Files
SkydiveLogs/Back/skydiveLogs-api/Controllers/TunnelController.cs
T
2026-03-25 21:19:16 +01:00

60 lines
1.6 KiB
C#

using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using skydiveLogs_api.DataContract;
using skydiveLogs_api.DomainBusiness.Interfaces;
namespace skydiveLogs_api.Controllers
{
public class TunnelController : Base
{
#region Public Constructors
public TunnelController(ITunnelService tunnelService,
IMapper mapper)
{
_tunnelService = tunnelService;
_mapper = mapper;
}
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Retrieves a list of all tunnels.
/// </summary>
/// <returns>A collection of TunnelResp objects containing all tunnels.</returns>
[HttpGet]
[EnableCors]
public IEnumerable<TunnelResp> Get()
{
var result = _tunnelService.GetAllTunnels();
return _mapper.Map<IEnumerable<TunnelResp>>(result);
}
/// <summary>
/// Retrieves a tunnel by its ID.
/// </summary>
/// <param name="id">The tunnel ID to retrieve.</param>
/// <returns>A TunnelResp object containing the tunnel details.</returns>
[HttpGet("{id}")]
[EnableCors]
public TunnelResp Get(int id)
{
var result = _tunnelService.GetTunnelById(id);
return _mapper.Map<TunnelResp>(result);
}
#endregion Public Methods
#region Private Fields
private readonly ITunnelService _tunnelService;
private readonly IMapper _mapper;
#endregion Private Fields
}
}