fix
This commit is contained in:
@@ -31,9 +31,9 @@ namespace skydiveLogs_api.Business
|
|||||||
return _imageRepository.GetById(id);
|
return _imageRepository.GetById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Image> GetAllImages()
|
public IEnumerable<Image> GetAllImages(User connectedUser)
|
||||||
{
|
{
|
||||||
return _imageRepository.GetAll();
|
return _imageRepository.GetAll(connectedUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateImage(int id, Image Image)
|
public void UpdateImage(int id, Image Image)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace skydiveLogs_api.Business.Interface
|
|||||||
{
|
{
|
||||||
public interface IImageService
|
public interface IImageService
|
||||||
{
|
{
|
||||||
IEnumerable<Image> GetAllImages();
|
IEnumerable<Image> GetAllImages(User connectedUser);
|
||||||
|
|
||||||
Image GetImageById(int id);
|
Image GetImageById(int id);
|
||||||
|
|
||||||
|
|||||||
@@ -18,159 +18,219 @@ namespace skydiveLogs_api.Business
|
|||||||
public IEnumerable<Statistic> GetStatsByAircraft(User connectedUser)
|
public IEnumerable<Statistic> GetStatsByAircraft(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.Aircraft.Name,
|
if (allJumps.Any())
|
||||||
j => j,
|
{
|
||||||
(groupby, jumps) => new Statistic
|
results = allJumps.GroupBy(j => j.Aircraft.Name,
|
||||||
{
|
j => j,
|
||||||
Label = groupby.ToString(),
|
(groupby, jumps) => new Statistic
|
||||||
Nb = jumps.Count()
|
{
|
||||||
})
|
Label = groupby.ToString(),
|
||||||
.ToList();
|
Nb = jumps.Count()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByDz(User connectedUser)
|
public IEnumerable<Statistic> GetStatsByDz(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.DropZone.Name,
|
if (allJumps.Any())
|
||||||
j => j,
|
{
|
||||||
(groupby, jumps) => new Statistic
|
results = allJumps.GroupBy(j => j.DropZone.Name,
|
||||||
{
|
j => j,
|
||||||
Label = groupby.ToString(),
|
(groupby, jumps) => new Statistic
|
||||||
Nb = jumps.Count()
|
{
|
||||||
})
|
Label = groupby.ToString(),
|
||||||
.ToList();
|
Nb = jumps.Count()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByJumpType(User connectedUser)
|
public IEnumerable<Statistic> GetStatsByJumpType(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.JumpType.Name,
|
if (allJumps.Any())
|
||||||
j => j,
|
{
|
||||||
(groupby, jumps) => new Statistic
|
results = allJumps.GroupBy(j => j.JumpType.Name,
|
||||||
{
|
j => j,
|
||||||
Label = groupby.ToString(),
|
(groupby, jumps) => new Statistic
|
||||||
Nb = jumps.Count()
|
{
|
||||||
})
|
Label = groupby.ToString(),
|
||||||
.ToList();
|
Nb = jumps.Count()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByGear(User connectedUser)
|
public IEnumerable<Statistic> GetStatsByGear(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.Gear.Name,
|
if (allJumps.Any())
|
||||||
j => j,
|
{
|
||||||
(groupby, jumps) => new Statistic
|
results = allJumps.GroupBy(j => j.Gear.Name,
|
||||||
{
|
j => j,
|
||||||
Label = groupby.ToString(),
|
(groupby, jumps) => new Statistic
|
||||||
Nb = jumps.Count()
|
{
|
||||||
})
|
Label = groupby.ToString(),
|
||||||
.ToList();
|
Nb = jumps.Count()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsByYear(User connectedUser)
|
public IEnumerable<Statistic> GetStatsByYear(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
return allJumps.GroupBy(j => j.JumpDate.Year,
|
if (allJumps.Any())
|
||||||
j => j,
|
{
|
||||||
(groupby, jumps) => new Statistic
|
results = allJumps.GroupBy(j => j.JumpDate.Year,
|
||||||
{
|
j => j,
|
||||||
Label = groupby.ToString(),
|
(groupby, jumps) => new Statistic
|
||||||
Nb = jumps.Count()
|
{
|
||||||
})
|
Label = groupby.ToString(),
|
||||||
.ToList();
|
Nb = jumps.Count()
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastYearByDz(User connectedUser)
|
public IEnumerable<Statistic> GetStatsForLastYearByDz(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
if (allJumps.Any())
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
return allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
results = allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
.GroupBy(j => j.DropZone.Name,
|
.GroupBy(j => j.DropZone.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new Statistic
|
||||||
{
|
{
|
||||||
Label = groupby.ToString(),
|
Label = groupby.ToString(),
|
||||||
Nb = jumps.Count()
|
Nb = jumps.Count()
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastYearByJumpType(User connectedUser)
|
public IEnumerable<Statistic> GetStatsForLastYearByJumpType(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
if (allJumps.Any())
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
{
|
||||||
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
|
||||||
return allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
results = allJumps.Where(j => j.JumpDate.Year == yearOfLastJump)
|
||||||
.GroupBy(j => j.JumpType.Name,
|
.GroupBy(j => j.JumpType.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new Statistic
|
||||||
{
|
{
|
||||||
Label = groupby.ToString(),
|
Label = groupby.ToString(),
|
||||||
Nb = jumps.Count()
|
Nb = jumps.Count()
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastMonthByDz(User connectedUser)
|
public IEnumerable<Statistic> GetStatsForLastMonthByDz(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
if (allJumps.Any())
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
{
|
||||||
var monthOfLastJump = lastJump.JumpDate.Month;
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
return allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
results = allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
||||||
.GroupBy(j => j.DropZone.Name,
|
.GroupBy(j => j.DropZone.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new Statistic
|
||||||
{
|
{
|
||||||
Label = groupby.ToString(),
|
Label = groupby.ToString(),
|
||||||
Nb = jumps.Count()
|
Nb = jumps.Count()
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType(User connectedUser)
|
public IEnumerable<Statistic> GetStatsForLastMonthByJumpType(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new List<Statistic>();
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
if (allJumps.Any())
|
||||||
var yearOfLastJump = lastJump.JumpDate.Year;
|
{
|
||||||
var monthOfLastJump = lastJump.JumpDate.Month;
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
|
var yearOfLastJump = lastJump.JumpDate.Year;
|
||||||
|
var monthOfLastJump = lastJump.JumpDate.Month;
|
||||||
|
|
||||||
return allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
results = allJumps.Where(j => j.JumpDate.Year == yearOfLastJump && j.JumpDate.Month == monthOfLastJump)
|
||||||
.GroupBy(j => j.JumpType.Name,
|
.GroupBy(j => j.JumpType.Name,
|
||||||
j => j,
|
j => j,
|
||||||
(groupby, jumps) => new Statistic
|
(groupby, jumps) => new Statistic
|
||||||
{
|
{
|
||||||
Label = groupby.ToString(),
|
Label = groupby.ToString(),
|
||||||
Nb = jumps.Count()
|
Nb = jumps.Count()
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleSummary GetSimpleSummary(User connectedUser)
|
public SimpleSummary GetSimpleSummary(User connectedUser)
|
||||||
{
|
{
|
||||||
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
var allJumps = _jumpService.GetAllJumps(connectedUser);
|
||||||
|
var results = new SimpleSummary();
|
||||||
|
|
||||||
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).FirstOrDefault();
|
if (allJumps.Any())
|
||||||
|
|
||||||
return new SimpleSummary
|
|
||||||
{
|
{
|
||||||
LastJump = lastJump,
|
var lastJump = allJumps.OrderByDescending(j => j.JumpDate).First();
|
||||||
TotalJumps = allJumps.Count(),
|
|
||||||
TotalCutaways = allJumps.Where(j => j.WithCutaway).Count()
|
results = new SimpleSummary
|
||||||
};
|
{
|
||||||
|
LastJump = lastJump,
|
||||||
|
TotalJumps = allJumps.Count(),
|
||||||
|
TotalCutaways = allJumps.Where(j => j.WithCutaway).Count()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IJumpService _jumpService;
|
private readonly IJumpService _jumpService;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IEnumerable<ImageResp> Get()
|
public IEnumerable<ImageResp> Get()
|
||||||
{
|
{
|
||||||
var result = _imageService.GetAllImages();
|
var result = _imageService.GetAllImages(ConnectedUser);
|
||||||
return _mapper.Map<IEnumerable<ImageResp>>(result);
|
return _mapper.Map<IEnumerable<ImageResp>>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user