Un oubli
This commit is contained in:
100
Back/skydiveLogs-api.DomainBusiness/StatsByAircraftService.cs
Normal file
100
Back/skydiveLogs-api.DomainBusiness/StatsByAircraftService.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
public class StatsByByAircraftService : IStatsByAircraftService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public StatsByByAircraftService(IJumpService jumpService,
|
||||
IIdentityService identityService,
|
||||
IStatsByAircraftRepository statsByAircraftRepository)
|
||||
{
|
||||
_jumpService = jumpService;
|
||||
_identityService = identityService;
|
||||
_statsByAircraftRepository = statsByAircraftRepository;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public IEnumerable<Statistic> GetStats()
|
||||
{
|
||||
// var allStats = GetAllStats();
|
||||
// if (!allStats.ByDz.Any())
|
||||
// {
|
||||
// var allJumps = _jumpService.GetAllJumps();
|
||||
// var results = new List<Statistic>();
|
||||
|
||||
// if (allJumps.Any())
|
||||
// {
|
||||
// results = [.. allJumps.GroupBy(j => j.DropZone.Name,
|
||||
// j => j,
|
||||
// (groupby, jumps) => new Statistic
|
||||
// {
|
||||
// Label = groupby.ToString(),
|
||||
// Nb = jumps.Count()
|
||||
// })];
|
||||
// }
|
||||
|
||||
// allStats.ByDz = results;
|
||||
// _userStatsRepository.Update(allStats);
|
||||
// }
|
||||
|
||||
// return allStats.ByDz;
|
||||
return null;
|
||||
}
|
||||
|
||||
// public void Reset()
|
||||
// {
|
||||
// var resetStats = new UserStats();
|
||||
// var myStats = GetAllStats();
|
||||
// myStats.ByAircraft = resetStats.ByAircraft;
|
||||
// myStats.ByDz = resetStats.ByDz;
|
||||
// myStats.ByGear = resetStats.ByGear;
|
||||
// myStats.ByJumpType = resetStats.ByJumpType;
|
||||
// myStats.ByYear = resetStats.ByYear;
|
||||
// myStats.ForLastMonthByDz = resetStats.ForLastMonthByDz;
|
||||
// myStats.ForLastMonthByJumpType = resetStats.ForLastMonthByJumpType;
|
||||
// myStats.ForLastYearByDz = resetStats.ForLastYearByDz;
|
||||
// myStats.ForLastYearByJumpType = resetStats.ForLastYearByJumpType;
|
||||
// myStats.ByYearByJumpType = resetStats.ByYearByJumpType;
|
||||
|
||||
// _userStatsRepository.Update(myStats);
|
||||
// }
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private UserStats GetAllStats()
|
||||
{
|
||||
var allStats = _statsByAircraftRepository.GetAll(_identityService.ConnectedUser);
|
||||
if (allStats == null)
|
||||
{
|
||||
allStats = new UserStats
|
||||
{
|
||||
User = _identityService.ConnectedUser
|
||||
};
|
||||
_statsByAircraftRepository.Add(allStats);
|
||||
}
|
||||
|
||||
return allStats;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IIdentityService _identityService;
|
||||
private readonly IJumpService _jumpService;
|
||||
private readonly IStatsByAircraftRepository _statsByAircraftRepository;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user