78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using AutoMapper;
|
|
using Microsoft.AspNetCore.Cors;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using skydiveLogs_api.DataContract;
|
|
using skydiveLogs_api.Domain;
|
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
|
using System.Collections.Generic;
|
|
|
|
namespace skydiveLogs_api.Controllers
|
|
{
|
|
public class TunnelFlightController : Base
|
|
{
|
|
#region Public Constructors
|
|
|
|
public TunnelFlightController(ITunnelFlightService tunnelFlightService,
|
|
IMapper mapper)
|
|
{
|
|
_tunnelFlightService = tunnelFlightService;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
// DELETE: api/Tunnel/5
|
|
//[HttpDelete("{id}")]
|
|
//[EnableCors]
|
|
//public void Delete(int id)
|
|
//{
|
|
// _tunnelService.DeleteTunnelById(id);
|
|
//}
|
|
|
|
// GET: api/TunnelFlight
|
|
[HttpGet]
|
|
[EnableCors]
|
|
public IEnumerable<TunnelFlightResp> Get()
|
|
{
|
|
var result = _tunnelFlightService.GetAllTunnelFlights();
|
|
return _mapper.Map<IEnumerable<TunnelFlightResp>>(result);
|
|
}
|
|
|
|
// GET: api/TunnelFlight/5
|
|
[HttpGet("{id}")]
|
|
[EnableCors]
|
|
public TunnelFlightResp Get(int id)
|
|
{
|
|
var result = _tunnelFlightService.GetTunnelFlightById(id);
|
|
return _mapper.Map<TunnelFlightResp>(result);
|
|
}
|
|
|
|
// POST: api/Tunnel
|
|
[HttpPost]
|
|
[EnableCors]
|
|
public void Post([FromBody] TunnelFlightReq value)
|
|
{
|
|
_tunnelFlightService.AddNewFlight(value.TunnelId,
|
|
_mapper.Map<TunnelFlight>(value));
|
|
}
|
|
|
|
// PUT: api/Tunnel/5
|
|
//[HttpPut("{id}")]
|
|
//[EnableCors]
|
|
//public void Put(int id, [FromBody] TunnelReq value)
|
|
//{
|
|
// _tunnelService.UpdateJumpType(id, _mapper.Map<Tunnel>(value));
|
|
//}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private readonly ITunnelFlightService _tunnelFlightService;
|
|
private readonly IMapper _mapper;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |