Add a feature to reset the user statistics.
This commit is contained in:
@@ -14,8 +14,7 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
IDropZoneService dropZoneService,
|
IDropZoneService dropZoneService,
|
||||||
IGearService gearService,
|
IGearService gearService,
|
||||||
IJumpRepository jumpRepository,
|
IJumpRepository jumpRepository,
|
||||||
IIdentityService identityService,
|
IIdentityService identityService)
|
||||||
IStatsService statsService)
|
|
||||||
{
|
{
|
||||||
_jumpTypeService = jumpTypeService;
|
_jumpTypeService = jumpTypeService;
|
||||||
_aircraftService = aircraftService;
|
_aircraftService = aircraftService;
|
||||||
@@ -23,7 +22,6 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
_gearService = gearService;
|
_gearService = gearService;
|
||||||
_jumpRepository = jumpRepository;
|
_jumpRepository = jumpRepository;
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_statsService = statsService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Constructors
|
#endregion Public Constructors
|
||||||
@@ -48,13 +46,11 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
jump.User = _identityService.ConnectedUser;
|
jump.User = _identityService.ConnectedUser;
|
||||||
|
|
||||||
_jumpRepository.Add(jump);
|
_jumpRepository.Add(jump);
|
||||||
_statsService.Reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteJumpById(int id)
|
public void DeleteJumpById(int id)
|
||||||
{
|
{
|
||||||
_jumpRepository.DeleteById(id);
|
_jumpRepository.DeleteById(id);
|
||||||
_statsService.Reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Jump> GetAllJumps()
|
public IEnumerable<Jump> GetAllJumps()
|
||||||
@@ -87,7 +83,6 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
private readonly IIdentityService _identityService;
|
private readonly IIdentityService _identityService;
|
||||||
private readonly IJumpRepository _jumpRepository;
|
private readonly IJumpRepository _jumpRepository;
|
||||||
private readonly IJumpTypeService _jumpTypeService;
|
private readonly IJumpTypeService _jumpTypeService;
|
||||||
private readonly IStatsService _statsService;
|
|
||||||
|
|
||||||
#endregion Private Fields
|
#endregion Private Fields
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -306,9 +306,19 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
|
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
var tmp = new UserStats();
|
var resetStats = new UserStats();
|
||||||
tmp.User = _identityService.ConnectedUser;
|
var myStats = GetAllStats();
|
||||||
_userStatsRepository.Add(tmp);
|
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;
|
||||||
|
|
||||||
|
_userStatsRepository.Update(myStats);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Public Methods
|
#endregion Public Methods
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ namespace skydiveLogs_api.Infrastructure
|
|||||||
|
|
||||||
public bool Update(UserStats stats)
|
public bool Update(UserStats stats)
|
||||||
{
|
{
|
||||||
|
//col.UpdateMany(x => new Customer { Name
|
||||||
|
// = x.Name.ToUpper(), Salary: 100 }, x => x.Name == "John")
|
||||||
|
|
||||||
return _col.Update(stats);
|
return _col.Update(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,13 @@ namespace skydiveLogs_api.Controllers
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("Reset")]
|
||||||
|
[EnableCors]
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_statsService.Reset();
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("Simple")]
|
[HttpGet("Simple")]
|
||||||
[EnableCors]
|
[EnableCors]
|
||||||
public SimpleSummaryResp Simple()
|
public SimpleSummaryResp Simple()
|
||||||
|
|||||||
Reference in New Issue
Block a user