Add an action to retrieve un simple summary with
the total of jumps and the last jump
This commit is contained in:
@@ -22,5 +22,7 @@ namespace skydiveLogs_api.Business.Interface
|
|||||||
IEnumerable<Statistic> GetStatsForLastMonthByDz();
|
IEnumerable<Statistic> GetStatsForLastMonthByDz();
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
|
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
|
||||||
|
|
||||||
|
SimpleSummary GetSimpleSummary();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,6 +159,20 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SimpleSummary GetSimpleSummary()
|
||||||
|
{
|
||||||
|
var allJumps = _jumpRepository.GetAll();
|
||||||
|
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||||
|
|
||||||
|
return new SimpleSummary
|
||||||
|
{
|
||||||
|
LastJump = lastJump,
|
||||||
|
TotalJumps = allJumps.Count(),
|
||||||
|
TotalCutaway = allJumps.Where(j => j.WithCutaway).Count()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private readonly IJumpRepository _jumpRepository;
|
private readonly IJumpRepository _jumpRepository;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
Back/skydiveLogs-api.Model/SimpleSummary.cs
Normal file
11
Back/skydiveLogs-api.Model/SimpleSummary.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace skydiveLogs_api.Model
|
||||||
|
{
|
||||||
|
public class SimpleSummary
|
||||||
|
{
|
||||||
|
public int TotalJumps { get; set; }
|
||||||
|
|
||||||
|
public int TotalCutaway { get; set; }
|
||||||
|
|
||||||
|
public Jump LastJump { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace skydiveLogs_api.Model
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Model
|
|
||||||
{
|
{
|
||||||
public class Statistic
|
public class Statistic
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,15 @@ namespace skydiveLogs_api.Controllers
|
|||||||
_mapper = mapper;
|
_mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("Simple")]
|
||||||
|
[EnableCors]
|
||||||
|
public SimpleSummaryResp Simple()
|
||||||
|
{
|
||||||
|
var result = _statsService.GetSimpleSummary();
|
||||||
|
|
||||||
|
return _mapper.Map<SimpleSummaryResp>(result);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("ByDz")]
|
[HttpGet("ByDz")]
|
||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IEnumerable<StatisticResp> ByDz()
|
public IEnumerable<StatisticResp> ByDz()
|
||||||
|
|||||||
11
Back/skydiveLogs-api/DataContract/SimpleSummaryResp.cs
Normal file
11
Back/skydiveLogs-api/DataContract/SimpleSummaryResp.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace skydiveLogs_api.DataContract
|
||||||
|
{
|
||||||
|
public class SimpleSummaryResp
|
||||||
|
{
|
||||||
|
public int TotalJumps { get; set; }
|
||||||
|
|
||||||
|
public int TotalCutaway { get; set; }
|
||||||
|
|
||||||
|
public JumpResp LastJump { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,8 @@ namespace skydiveLogs_api.Mapper
|
|||||||
CreateMap<Model.Aircraft ,DataContract.AircraftResp>();
|
CreateMap<Model.Aircraft ,DataContract.AircraftResp>();
|
||||||
CreateMap<Model.DropZone ,DataContract.DropZoneResp>();
|
CreateMap<Model.DropZone ,DataContract.DropZoneResp>();
|
||||||
CreateMap<Model.Statistic ,DataContract.StatisticResp>();
|
CreateMap<Model.Statistic ,DataContract.StatisticResp>();
|
||||||
|
|
||||||
|
CreateMap<Model.SimpleSummary, DataContract.SimpleSummaryResp>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user