Add AutoMapper config to convert the return data API
This commit is contained in:
@@ -7,10 +7,14 @@ namespace skydiveLogs_api.Business.Interface
|
|||||||
{
|
{
|
||||||
public interface IAircraftService
|
public interface IAircraftService
|
||||||
{
|
{
|
||||||
IEnumerable<skydiveLogs_api.DataContract.AircraftResp> GetAllAircrafts();
|
IEnumerable<Aircraft> GetAllAircrafts();
|
||||||
skydiveLogs_api.DataContract.AircraftResp GetAircraftById(int id);
|
|
||||||
|
Aircraft GetAircraftById(int id);
|
||||||
|
|
||||||
void AddNewAircraft(Aircraft aircraft);
|
void AddNewAircraft(Aircraft aircraft);
|
||||||
|
|
||||||
void UpdateAircraft(int id, Aircraft aircraft);
|
void UpdateAircraft(int id, Aircraft aircraft);
|
||||||
|
|
||||||
void DeleteAircraftById(int id);
|
void DeleteAircraftById(int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,14 @@ namespace skydiveLogs_api.Business.Interface
|
|||||||
{
|
{
|
||||||
public interface IDropZoneService
|
public interface IDropZoneService
|
||||||
{
|
{
|
||||||
IEnumerable<skydiveLogs_api.DataContract.DropZoneResp> GetAllDzs();
|
IEnumerable<DropZone> GetAllDzs();
|
||||||
skydiveLogs_api.DataContract.DropZoneResp GetDzById(int id);
|
|
||||||
|
DropZone GetDzById(int id);
|
||||||
|
|
||||||
void DeleteDzById(int id);
|
void DeleteDzById(int id);
|
||||||
|
|
||||||
void UpdateDz(int id, DropZone dropZone);
|
void UpdateDz(int id, DropZone dropZone);
|
||||||
|
|
||||||
void AddNewDz(DropZone dropZone);
|
void AddNewDz(DropZone dropZone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,14 @@ namespace skydiveLogs_api.Business.Interface
|
|||||||
{
|
{
|
||||||
public interface IJumpService
|
public interface IJumpService
|
||||||
{
|
{
|
||||||
IEnumerable<skydiveLogs_api.DataContract.JumpResp> GetAllJumps();
|
IEnumerable<Jump> GetAllJumps();
|
||||||
skydiveLogs_api.DataContract.JumpResp GetJumpById(int id);
|
|
||||||
|
Jump GetJumpById(int id);
|
||||||
|
|
||||||
void AddNewJump(Jump jump);
|
void AddNewJump(Jump jump);
|
||||||
|
|
||||||
void UpdateJump(int id, Jump jump);
|
void UpdateJump(int id, Jump jump);
|
||||||
|
|
||||||
void DeleteJumpById(int id);
|
void DeleteJumpById(int id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,14 +26,16 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IEnumerable<AircraftResp> Get()
|
public IEnumerable<AircraftResp> Get()
|
||||||
{
|
{
|
||||||
return _aircraftService.GetAllAircrafts();
|
var result = _aircraftService.GetAllAircrafts();
|
||||||
|
return _mapper.Map<IEnumerable<AircraftResp>>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/Aircraft/5
|
// GET: api/Aircraft/5
|
||||||
[HttpGet("{id}", Name = "Get")]
|
[HttpGet("{id}", Name = "Get")]
|
||||||
public AircraftResp Get(int id)
|
public AircraftResp Get(int id)
|
||||||
{
|
{
|
||||||
return _aircraftService.GetAircraftById(id);
|
var result = _aircraftService.GetAircraftById(id);
|
||||||
|
return _mapper.Map<AircraftResp>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST: api/Aircraft
|
// POST: api/Aircraft
|
||||||
|
|||||||
@@ -26,14 +26,18 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IEnumerable<DropZoneResp> Get()
|
public IEnumerable<DropZoneResp> Get()
|
||||||
{
|
{
|
||||||
return _dropZoneService.GetAllDzs();
|
var result = _dropZoneService.GetAllDzs();
|
||||||
|
|
||||||
|
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/DropZone/5
|
// GET: api/DropZone/5
|
||||||
[HttpGet("{id}", Name = "Get")]
|
[HttpGet("{id}", Name = "Get")]
|
||||||
public DropZoneResp Get(int id)
|
public DropZoneResp Get(int id)
|
||||||
{
|
{
|
||||||
return _dropZoneService.GetDzById(id);
|
var result = _dropZoneService.GetDzById(id);
|
||||||
|
|
||||||
|
return _mapper.Map<DropZoneResp>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST: api/DropZone
|
// POST: api/DropZone
|
||||||
|
|||||||
@@ -26,14 +26,16 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IEnumerable<JumpResp> Get()
|
public IEnumerable<JumpResp> Get()
|
||||||
{
|
{
|
||||||
return _jumpService.GetAllJumps();
|
var result = _jumpService.GetAllJumps();
|
||||||
|
return _mapper.Map<IEnumerable<JumpResp>>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/Jump/5
|
// GET: api/Jump/5
|
||||||
[HttpGet("{id}", Name = "Get")]
|
[HttpGet("{id}", Name = "Get")]
|
||||||
public JumpResp Get(int id)
|
public JumpResp Get(int id)
|
||||||
{
|
{
|
||||||
return _jumpService.GetJumpById(id);
|
var result = _jumpService.GetJumpById(id);
|
||||||
|
return _mapper.Map<JumpResp>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST: api/Jump
|
// POST: api/Jump
|
||||||
|
|||||||
@@ -26,14 +26,16 @@ namespace skydiveLogs_api.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IEnumerable<JumpTypeResp> Get()
|
public IEnumerable<JumpTypeResp> Get()
|
||||||
{
|
{
|
||||||
return _jumpTypeService.GetAllJumpTypes();
|
var result = _jumpTypeService.GetAllJumpTypes();
|
||||||
|
return _mapper.Map<IEnumerable<JumpTypeResp>>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/JumpType/5
|
// GET: api/JumpType/5
|
||||||
[HttpGet("{id}", Name = "Get")]
|
[HttpGet("{id}", Name = "Get")]
|
||||||
public JumpTypeResp Get(int id)
|
public JumpTypeResp Get(int id)
|
||||||
{
|
{
|
||||||
return _jumpTypeService.GetJumpTypeById(id);
|
var result = _jumpTypeService.GetJumpTypeById(id);
|
||||||
|
return _mapper.Map<JumpTypeResp>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// POST: api/JumpType
|
// POST: api/JumpType
|
||||||
|
|||||||
@@ -13,6 +13,11 @@ namespace skydiveLogs_api.Mapper
|
|||||||
CreateMap<DataContract.JumpTypeReq, Model.JumpType>();
|
CreateMap<DataContract.JumpTypeReq, Model.JumpType>();
|
||||||
CreateMap<DataContract.AircraftReq, Model.Aircraft>();
|
CreateMap<DataContract.AircraftReq, Model.Aircraft>();
|
||||||
CreateMap<DataContract.DropZoneReq, Model.DropZone>();
|
CreateMap<DataContract.DropZoneReq, Model.DropZone>();
|
||||||
|
|
||||||
|
CreateMap<Model.Jump, DataContract.JumpReq>();
|
||||||
|
CreateMap<Model.JumpType ,DataContract.JumpTypeResp>();
|
||||||
|
CreateMap<Model.Aircraft ,DataContract.AircraftResp>();
|
||||||
|
CreateMap<Model.DropZone ,DataContract.DropZoneResp>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user