78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
|
using skydiveLogs_api.DomainService.Repositories;
|
|
using skydiveLogs_api.Domain;
|
|
|
|
|
|
namespace skydiveLogs_api.DomainBusiness
|
|
{
|
|
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,
|
|
User connectedUser)
|
|
{
|
|
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;
|
|
jump.User = connectedUser;
|
|
|
|
_jumpRepository.Add(jump);
|
|
}
|
|
|
|
public void DeleteJumpById(int id)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public IEnumerable<Jump> GetAllJumps(User connectedUser)
|
|
{
|
|
return _jumpRepository.GetAll(connectedUser);
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|