Ajout de l'implémentation des stats par dz, avion, piège et annèe.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using skydiveLogs_api.Business.Interface;
|
||||
using skydiveLogs_api.Data.Interface;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Business
|
||||
{
|
||||
public class DropZoneService : IDropZoneService
|
||||
|
||||
18
Back/skydiveLogs-api.Business/Interface/IStatsService.cs
Normal file
18
Back/skydiveLogs-api.Business/Interface/IStatsService.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using skydiveLogs_api.Model;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace skydiveLogs_api.Business.Interface
|
||||
{
|
||||
public interface IStatsService
|
||||
{
|
||||
IEnumerable<Statistic> GetStatsByDz();
|
||||
|
||||
IEnumerable<Statistic> GetStatsByAircraft();
|
||||
|
||||
IEnumerable<Statistic> GetStatsByJumpType();
|
||||
|
||||
IEnumerable<Statistic> GetStatsByRig();
|
||||
|
||||
IEnumerable<Statistic> GetStatsByYear();
|
||||
}
|
||||
}
|
||||
90
Back/skydiveLogs-api.Business/StatsService.cs
Normal file
90
Back/skydiveLogs-api.Business/StatsService.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using skydiveLogs_api.Business.Interface;
|
||||
using skydiveLogs_api.Data.Interface;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Business
|
||||
{
|
||||
public class StatsService : IStatsService
|
||||
{
|
||||
public StatsService(IJumpRepository jumpRepository)
|
||||
{
|
||||
_jumpRepository = jumpRepository;
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsByAircraft()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAllJumps();
|
||||
|
||||
return allJumps.GroupBy(j => j.AircraftId,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsByDz()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAllJumps();
|
||||
|
||||
return allJumps.GroupBy(j => j.DropZoneId,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsByJumpType()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAllJumps();
|
||||
|
||||
return allJumps.GroupBy(j => j.JumpTypeId,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsByRig()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAllJumps();
|
||||
|
||||
return allJumps.GroupBy(j => j.GearId,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Statistic> GetStatsByYear()
|
||||
{
|
||||
var allJumps = _jumpRepository.GetAllJumps();
|
||||
|
||||
return allJumps.GroupBy(j => j.JumpDate.Year,
|
||||
j => j,
|
||||
(groupby, jumps) => new Statistic
|
||||
{
|
||||
Label = groupby.ToString(),
|
||||
Nb = jumps.Count()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private readonly IJumpRepository _jumpRepository;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user