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 /// /// Retrieves a list of all tunnels. /// /// A collection of TunnelResp objects containing all tunnels. [HttpGet] [EnableCors] public IEnumerable Get() { var result = _tunnelService.GetAllTunnels(); return _mapper.Map>(result); } /// /// Retrieves a tunnel by its ID. /// /// The tunnel ID to retrieve. /// A TunnelResp object containing the tunnel details. [HttpGet("{id}")] [EnableCors] public TunnelResp Get(int id) { var result = _tunnelService.GetTunnelById(id); return _mapper.Map(result); } #endregion Public Methods #region Private Fields private readonly ITunnelService _tunnelService; private readonly IMapper _mapper; #endregion Private Fields } }