This commit is contained in:
Sébastien André
2020-03-04 22:49:01 +01:00
12 changed files with 125 additions and 32 deletions

View File

@@ -22,5 +22,7 @@ namespace skydiveLogs_api.Business.Interface
IEnumerable<Statistic> GetStatsForLastMonthByDz();
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
SimpleSummary GetSimpleSummary();
}
}

View File

@@ -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;
}
}

View 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; }
}
}

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace skydiveLogs_api.Model
namespace skydiveLogs_api.Model
{
public class Statistic
{

View File

@@ -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()

View 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; }
}
}

View File

@@ -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>();
}
}
}