Différencier Tunnel et TunnelFlight

This commit is contained in:
Sébastien ANDRE
2023-06-12 16:02:48 +02:00
parent 7856989866
commit da09a8d23b
14 changed files with 216 additions and 51 deletions

View File

@@ -2,7 +2,6 @@
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;
@@ -23,14 +22,6 @@ namespace skydiveLogs_api.Controllers
#region Public Methods
// DELETE: api/Tunnel/5
//[HttpDelete("{id}")]
//[EnableCors]
//public void Delete(int id)
//{
// _tunnelService.DeleteTunnelById(id);
//}
// GET: api/Tunnel
[HttpGet]
[EnableCors]
@@ -49,23 +40,6 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<TunnelResp>(result);
}
// POST: api/Tunnel
[HttpPost]
[EnableCors]
public void Post([FromBody] TunnelFlightReq value)
{
_tunnelService.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

View File

@@ -0,0 +1,78 @@
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
}
}

View File

@@ -14,4 +14,4 @@ namespace skydiveLogs_api.DataContract
public DateTime FlightDate { get; set; }
}
}
}

View File

@@ -0,0 +1,17 @@
using System;
namespace skydiveLogs_api.DataContract
{
public class TunnelFlightResp
{
public int Id { get; set; }
public int TunnelId { get; set; }
public int NbMinutes { get; set; }
public string Notes { get; set; }
public DateTime FlightDate { get; set; }
}
}

View File

@@ -33,6 +33,7 @@ namespace skydiveLogs_api.Mapper
CreateMap<User, DataContract.UserResp>();
CreateMap<UserImage, DataContract.ImageResp>();
CreateMap<Tunnel, DataContract.TunnelResp>();
CreateMap<TunnelFlight, DataContract.TunnelFlightResp>();
CreateMap<SimpleSummary, DataContract.SimpleSummaryResp>();
}