Implement the function "Add a aircraft"

This commit is contained in:
Sébastien André
2019-12-04 13:51:28 +01:00
parent 6091b2bffa
commit 91b31afd0d
5 changed files with 24 additions and 12 deletions

View File

@@ -15,9 +15,9 @@ namespace skydiveLogs_api.Business
_aircraftRepository = aircraftRepository;
}
public void AddNewAircraft(Aircraft aircraft)
public void AddNewAircraft(Aircraft newAircraft)
{
throw new NotImplementedException();
_aircraftRepository.AddAircraft(newAircraft);
}
public void DeleteAircraftById(int id)

View File

@@ -39,10 +39,6 @@ namespace skydiveLogs_api.Business
{
dropZone.Id = id;
//dropZone.Address = dropZone.Address ?? string.Empty;
//dropZone.Website = dropZone.Address ?? string.Empty;
//dropZone.Email = dropZone.Address ?? string.Empty;
return _dropZoneRepository.Update(dropZone);
}

View File

@@ -32,6 +32,23 @@ namespace skydiveLogs_api.Data
return _col.Update(aircraft);
}
public bool AddAircraft(Aircraft newAircraft)
{
var result = true;
try
{
_col.Insert(newAircraft);
}
catch
{
result = false;
}
return result;
}
private readonly IDataProvider _dataProvider;
private readonly LiteCollection<Aircraft> _col;

View File

@@ -5,5 +5,6 @@ namespace skydiveLogs_api.Data.Interface
{
public interface IAircraftRepository : IRepository<Aircraft>
{
bool AddAircraft(Aircraft newAircraft);
}
}

View File

@@ -1,11 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace skydiveLogs_api.DataContract
namespace skydiveLogs_api.DataContract
{
public class AircraftReq
{
public int Id { get; set; }
public string Name { get; set; }
}
}