Fix in Stats : add the connectedUser
This commit is contained in:
@@ -5,24 +5,24 @@ namespace skydiveLogs_api.Business.Interface
|
|||||||
{
|
{
|
||||||
public interface IStatsService
|
public interface IStatsService
|
||||||
{
|
{
|
||||||
IEnumerable<Statistic> GetStatsByDz();
|
IEnumerable<Statistic> GetStatsByDz(User connectedUser);
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByAircraft();
|
IEnumerable<Statistic> GetStatsByAircraft(User connectedUser);
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByJumpType();
|
IEnumerable<Statistic> GetStatsByJumpType(User connectedUser);
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByGear();
|
IEnumerable<Statistic> GetStatsByGear(User connectedUser);
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsByYear();
|
IEnumerable<Statistic> GetStatsByYear(User connectedUser);
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastYearByDz();
|
IEnumerable<Statistic> GetStatsForLastYearByDz(User connectedUser);
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastYearByJumpType();
|
IEnumerable<Statistic> GetStatsForLastYearByJumpType(User connectedUser);
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastMonthByDz();
|
IEnumerable<Statistic> GetStatsForLastMonthByDz(User connectedUser);
|
||||||
|
|
||||||
IEnumerable<Statistic> GetStatsForLastMonthByJumpType();
|
IEnumerable<Statistic> GetStatsForLastMonthByJumpType(User connectedUser);
|
||||||
|
|
||||||
SimpleSummary GetSimpleSummary();
|
SimpleSummary GetSimpleSummary(User connectedUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ namespace skydiveLogs_api.Business
|
|||||||
{
|
{
|
||||||
public class StatsService : IStatsService
|
public class StatsService : IStatsService
|
||||||
{
|
{
|
||||||
public StatsService(IJumpRepository jumpRepository)
|
public StatsService(IJumpService jumpService)
|
||||||
{
|
{
|
||||||
_jumpRepository = jumpRepository;
|
_jumpService = jumpService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByAircraft()
|
public IEnumerable<Statistic> GetStatsByAircraft(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.Aircraft.Name,
|
return allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
j => j,
|
j => j,
|
||||||
@@ -29,9 +29,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByDz()
|
public IEnumerable<Statistic> GetStatsByDz(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.DropZone.Name,
|
return allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
j => j,
|
j => j,
|
||||||
@@ -43,9 +43,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByJumpType()
|
public IEnumerable<Statistic> GetStatsByJumpType(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.JumpType.Name,
|
return allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
j => j,
|
j => j,
|
||||||
@@ -57,9 +57,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByGear()
|
public IEnumerable<Statistic> GetStatsByGear(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.Gear.Name,
|
return allJumps.GroupBy(j => j.Gear.Name,
|
||||||
j => j,
|
j => j,
|
||||||
@@ -71,9 +71,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByYear()
|
public IEnumerable<Statistic> GetStatsByYear(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.JumpDate.Year,
|
return allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
j => j,
|
j => j,
|
||||||
@@ -85,9 +85,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastYearByDz()
|
public IEnumerable<Statistic> GetStatsForLastYearByDz(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
@@ -103,9 +103,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastYearByJumpType()
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
@@ -121,9 +121,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastMonthByDz()
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
@@ -140,9 +140,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType()
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
@@ -159,9 +159,9 @@ namespace skydiveLogs_api.Business
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary()
|
public SimpleSummary GetSimpleSummary(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpRepository.GetAll();
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
||||||
|
|
||||||
@@ -173,6 +173,6 @@ namespace skydiveLogs_api.Business
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IJumpRepository _jumpRepository;
|
private readonly IJumpService _jumpService;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public SimpleSummaryResp Simple()
|
public SimpleSummaryResp Simple()
|
||||||
{
|
{
|
||||||
var result = _statsService.GetSimpleSummary();
|
var result = _statsService.GetSimpleSummary(ConnectedUser);
|
||||||
|
|
||||||
return _mapper.Map<SimpleSummaryResp>(result);
|
return _mapper.Map<SimpleSummaryResp>(result);
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IEnumerable<StatisticResp> ByDz()
|
public IEnumerable<StatisticResp> ByDz()
|
||||||
{
|
{
|
||||||
var result = _statsService.GetStatsByDz();
|
var result = _statsService.GetStatsByDz(ConnectedUser);
|
||||||
|
|
||||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IEnumerable<StatisticResp> ByAircraft()
|
public IEnumerable<StatisticResp> ByAircraft()
|
||||||
{
|
{
|
||||||
var result = _statsService.GetStatsByAircraft();
|
var result = _statsService.GetStatsByAircraft(ConnectedUser);
|
||||||
|
|
||||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IEnumerable<StatisticResp> ByJumpType()
|
public IEnumerable<StatisticResp> ByJumpType()
|
||||||
{
|
{
|
||||||
var result = _statsService.GetStatsByJumpType();
|
var result = _statsService.GetStatsByJumpType(ConnectedUser);
|
||||||
|
|
||||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IEnumerable<StatisticResp> ByGear()
|
public IEnumerable<StatisticResp> ByGear()
|
||||||
{
|
{
|
||||||
var result = _statsService.GetStatsByGear();
|
var result = _statsService.GetStatsByGear(ConnectedUser);
|
||||||
|
|
||||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IEnumerable<StatisticResp> ByYear()
|
public IEnumerable<StatisticResp> ByYear()
|
||||||
{
|
{
|
||||||
var result = _statsService.GetStatsByYear();
|
var result = _statsService.GetStatsByYear(ConnectedUser);
|
||||||
|
|
||||||
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
return _mapper.Map<IEnumerable<StatisticResp>>(result);
|
||||||
}
|
}
|
||||||
@@ -77,8 +77,8 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public StatisticForLastYearResp ForLastYear()
|
public StatisticForLastYearResp ForLastYear()
|
||||||
{
|
{
|
||||||
var resultByDz = _statsService.GetStatsForLastYearByDz();
|
var resultByDz = _statsService.GetStatsForLastYearByDz(ConnectedUser);
|
||||||
var resultByJumpType = _statsService.GetStatsForLastYearByJumpType();
|
var resultByJumpType = _statsService.GetStatsForLastYearByJumpType(ConnectedUser);
|
||||||
|
|
||||||
var result = new StatisticForLastYearResp();
|
var result = new StatisticForLastYearResp();
|
||||||
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
|
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
|
||||||
@@ -91,8 +91,8 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public StatisticForLastMonthResp ForLastMonth()
|
public StatisticForLastMonthResp ForLastMonth()
|
||||||
{
|
{
|
||||||
var resultByDz = _statsService.GetStatsForLastMonthByDz();
|
var resultByDz = _statsService.GetStatsForLastMonthByDz(ConnectedUser);
|
||||||
var resultByJumpType = _statsService.GetStatsForLastMonthByJumpType();
|
var resultByJumpType = _statsService.GetStatsForLastMonthByJumpType(ConnectedUser);
|
||||||
|
|
||||||
var result = new StatisticForLastMonthResp();
|
var result = new StatisticForLastMonthResp();
|
||||||
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
|
result.ByDz = _mapper.Map<IEnumerable<StatisticResp>>(resultByDz);
|
||||||
|
|||||||
Reference in New Issue
Block a user