Add controler, domain and service about "Tunnel"
This commit is contained in:
76
Back/skydiveLogs-api/Controllers/TunnelController.cs
Normal file
76
Back/skydiveLogs-api/Controllers/TunnelController.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using skydiveLogs_api.DataContract;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
|
||||
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
|
||||
|
||||
// DELETE: api/Tunnel/5
|
||||
//[HttpDelete("{id}")]
|
||||
//[EnableCors]
|
||||
//public void Delete(int id)
|
||||
//{
|
||||
// _tunnelService.DeleteTunnelById(id);
|
||||
//}
|
||||
|
||||
// GET: api/Tunnel
|
||||
[HttpGet]
|
||||
[EnableCors]
|
||||
public IEnumerable<TunnelResp> Get()
|
||||
{
|
||||
var result = _tunnelService.GetAllTunnels();
|
||||
return _mapper.Map<IEnumerable<TunnelResp>>(result);
|
||||
}
|
||||
|
||||
// GET: api/Tunnel/5
|
||||
[HttpGet("{id}")]
|
||||
[EnableCors]
|
||||
public TunnelResp Get(int id)
|
||||
{
|
||||
var result = _tunnelService.GetTunnelById(id);
|
||||
return _mapper.Map<TunnelResp>(result);
|
||||
}
|
||||
|
||||
// POST: api/Tunnel
|
||||
//[HttpPost]
|
||||
//[EnableCors]
|
||||
//public void Post([FromBody] TunnelReq value)
|
||||
//{
|
||||
// _tunnelService.AddNewJumpType(_mapper.Map<Tunnel>(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 ITunnelService _tunnelService;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
21
Back/skydiveLogs-api/DataContract/TunnelReq.cs
Normal file
21
Back/skydiveLogs-api/DataContract/TunnelReq.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.DataContract
|
||||
{
|
||||
public class TunnelReq
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Latitude { get; set; }
|
||||
|
||||
public string Longitude { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
public string Website { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
}
|
||||
}
|
||||
19
Back/skydiveLogs-api/DataContract/TunnelResp.cs
Normal file
19
Back/skydiveLogs-api/DataContract/TunnelResp.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace skydiveLogs_api.DataContract
|
||||
{
|
||||
public class TunnelResp
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Latitude { get; set; }
|
||||
|
||||
public string Longitude { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
public string Website { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ namespace skydiveLogs_api.Mapper
|
||||
CreateMap<DataContract.GearReq, Gear>();
|
||||
CreateMap<DataContract.UserReq, User>();
|
||||
CreateMap<DataContract.ImageReq, UserImage>();
|
||||
CreateMap<DataContract.TunnelReq, Tunnel>();
|
||||
|
||||
CreateMap<Gear, DataContract.GearResp>();
|
||||
CreateMap<Jump, DataContract.JumpResp>().ForMember(dest => dest.AircraftId, opt => opt.MapFrom(s => s.Aircraft.Id))
|
||||
@@ -31,6 +32,7 @@ namespace skydiveLogs_api.Mapper
|
||||
CreateMap<Statistic, DataContract.StatisticResp>();
|
||||
CreateMap<User, DataContract.UserResp>();
|
||||
CreateMap<UserImage, DataContract.ImageResp>();
|
||||
CreateMap<Tunnel, DataContract.TunnelResp>();
|
||||
|
||||
CreateMap<SimpleSummary, DataContract.SimpleSummaryResp>();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.6" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.28.1" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.30.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user