Merge branch 'master' of https://home.git.sebastienandre.com/sandre/SkydiveLogs
This commit is contained in:
@@ -22,5 +22,7 @@ namespace skydiveLogs_api.Business.Interface
|
||||
IEnumerable<Statistic> GetStatsForLastMonthByDz();
|
||||
|
||||
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
|
||||
|
||||
SimpleSummary GetSimpleSummary();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,6 +159,20 @@ namespace skydiveLogs_api.Business
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public SimpleSummary GetSimpleSummary()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAll();
|
||||
|
||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||
|
||||
return new SimpleSummary
|
||||
{
|
||||
LastJump = lastJump,
|
||||
TotalJumps = allJumps.Count(),
|
||||
TotalCutaways = allJumps.Where(j => j.WithCutaway).Count()
|
||||
};
|
||||
}
|
||||
|
||||
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 TotalCutaways { get; set; }
|
||||
|
||||
public Jump LastJump { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace skydiveLogs_api.Model
|
||||
namespace skydiveLogs_api.Model
|
||||
{
|
||||
public class Statistic
|
||||
{
|
||||
|
||||
@@ -21,6 +21,15 @@ namespace skydiveLogs_api.Controllers
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
[HttpGet("Simple")]
|
||||
[EnableCors]
|
||||
public SimpleSummaryResp Simple()
|
||||
{
|
||||
var result = _statsService.GetSimpleSummary();
|
||||
|
||||
return _mapper.Map<SimpleSummaryResp>(result);
|
||||
}
|
||||
|
||||
[HttpGet("ByDz")]
|
||||
[EnableCors]
|
||||
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 TotalCutaways { get; set; }
|
||||
|
||||
public JumpResp LastJump { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,8 @@ namespace skydiveLogs_api.Mapper
|
||||
CreateMap<Model.Aircraft ,DataContract.AircraftResp>();
|
||||
CreateMap<Model.DropZone ,DataContract.DropZoneResp>();
|
||||
CreateMap<Model.Statistic ,DataContract.StatisticResp>();
|
||||
|
||||
CreateMap<Model.SimpleSummary, DataContract.SimpleSummaryResp>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user