Add an endpoint to call the lof of jumps by page.

This commit is contained in:
Sébastien André
2022-05-08 16:42:04 +02:00
parent 0745943c5b
commit 9e18b7708a
16 changed files with 142 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ using skydiveLogs_api.DataContract;
using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Controllers
{
@@ -34,11 +35,32 @@ namespace skydiveLogs_api.Controllers
// GET: api/Jump
[HttpGet]
[EnableCors]
public IEnumerable<JumpResp> Get()
public JumpListResp Get()
{
var result = _jumpService.GetAllJumps();
var tmp = _jumpService.GetAllJumps();
var result = new JumpListResp
{
Rows = _mapper.Map<IEnumerable<JumpResp>>(tmp),
Count = tmp.Count()
};
return _mapper.Map<IEnumerable<JumpResp>>(result);
return result;
}
// GET: api/Jump/5/10
[HttpGet("{beginJumpIndex}/{endJumpIndex}")]
[EnableCors]
public JumpListResp Get(int beginJumpIndex, int endJumpIndex)
{
var totalJumps = _jumpService.GetJumpCount();
var tmp = _jumpService.GetJumpsByIndexes(beginJumpIndex, endJumpIndex);
var result = new JumpListResp
{
Rows = _mapper.Map<IEnumerable<JumpResp>>(tmp),
Count = totalJumps
};
return result;
}
// GET: api/Jump/5

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace skydiveLogs_api.DataContract
{
public class JumpListResp
{
#region Public Properties
public int Count { get; set; }
public IEnumerable<JumpResp> Rows { get; set; }
#endregion Public Properties
}
}