Add Gear controller/service/repo and relations in db between Jumps and others objects

This commit is contained in:
Sébastien André
2019-11-22 23:19:17 +01:00
parent 29740709c6
commit b9a29bcd79
12 changed files with 178 additions and 13 deletions

View File

@@ -10,13 +10,35 @@ namespace skydiveLogs_api.Business
{
public class JumpService : IJumpService
{
public JumpService(IJumpRepository jumpRepository)
public JumpService(IJumpTypeService jumpTypeService,
IAircraftService aircraftService,
IDropZoneService dropZoneService,
IGearService gearService,
IJumpRepository jumpRepository)
{
_jumpTypeService = jumpTypeService;
_aircraftService = aircraftService;
_dropZoneService = dropZoneService;
_gearService = gearService;
_jumpRepository = jumpRepository;
}
public void AddNewJump(Jump jump)
public void AddNewJump(int aircraftId,
int dzId,
int jumpTypeId,
int gearId,
Jump jump)
{
var selectedGear = _gearService.GetGearById(gearId);
var selectedJumpType = _jumpTypeService.GetJumpTypeById(jumpTypeId);
var selectedAircraft = _aircraftService.GetAircraftById(aircraftId);
var selectedDropZone = _dropZoneService.GetDzById(dzId);
jump.Aircraft = selectedAircraft;
jump.JumpType = selectedJumpType;
jump.DropZone = selectedDropZone;
jump.Gear = selectedGear;
_jumpRepository.AddJump(jump);
}
@@ -41,5 +63,13 @@ namespace skydiveLogs_api.Business
}
private readonly IJumpRepository _jumpRepository;
private readonly IJumpTypeService _jumpTypeService;
private readonly IAircraftService _aircraftService;
private readonly IDropZoneService _dropZoneService;
private readonly IGearService _gearService;
}
}