Files
SkydiveLogs/Back/skydiveLogs-api.Business/JumpService.cs
2019-12-05 08:32:09 +01:00

76 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using skydiveLogs_api.Business.Interface;
using skydiveLogs_api.Model;
using skydiveLogs_api.Data.Interface;
namespace skydiveLogs_api.Business
{
public class JumpService : IJumpService
{
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(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.Add(jump);
}
public void DeleteJumpById(int id)
{
throw new NotImplementedException();
}
public IEnumerable<Jump> GetAllJumps()
{
return _jumpRepository.GetAll();
}
public Jump GetJumpById(int id)
{
return _jumpRepository.GetById(id);
}
public void UpdateJump(int id, Jump jump)
{
throw new NotImplementedException();
}
private readonly IJumpRepository _jumpRepository;
private readonly IJumpTypeService _jumpTypeService;
private readonly IAircraftService _aircraftService;
private readonly IDropZoneService _dropZoneService;
private readonly IGearService _gearService;
}
}