Files
SkydiveLogs/Back/skydiveLogs-api.Business/JumpService.cs
Sébastien André eee6f596ac Update about the relation column "User" for the images
and begin to add a column in "Aircraft"
2020-07-30 18:29:41 +02:00

78 lines
2.4 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,
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;
}
}