Add AutoMapper and update the interface of business services
This commit is contained in:
@@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using skydiveLogs_api.Business.Interface;
|
||||
using skydiveLogs_api.DataContract;
|
||||
using AutoMapper;
|
||||
using skydiveLogs_api.Model;
|
||||
|
||||
namespace skydiveLogs_api.Controllers
|
||||
{
|
||||
@@ -13,43 +15,49 @@ namespace skydiveLogs_api.Controllers
|
||||
[ApiController]
|
||||
public class DropZoneController : ControllerBase
|
||||
{
|
||||
public DropZoneController(IDropZoneService dropZoneService)
|
||||
public DropZoneController(IDropZoneService dropZoneService,
|
||||
IMapper mapper)
|
||||
{
|
||||
_dropZoneService = dropZoneService;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
// GET: api/DropZone
|
||||
[HttpGet]
|
||||
public IEnumerable<DropZoneResp> Get()
|
||||
{
|
||||
return new DropZoneResp[] { "value1", "value2" };
|
||||
return _dropZoneService.GetAllDzs();
|
||||
}
|
||||
|
||||
// GET: api/DropZone/5
|
||||
[HttpGet("{id}", Name = "Get")]
|
||||
public DropZoneResp Get(int id)
|
||||
{
|
||||
return "value";
|
||||
return _dropZoneService.GetDzById(id);
|
||||
}
|
||||
|
||||
// POST: api/DropZone
|
||||
[HttpPost]
|
||||
public void Post([FromBody] DropZoneReq value)
|
||||
{
|
||||
_dropZoneService.AddNewDz(_mapper.Map<DropZone>(value));
|
||||
}
|
||||
|
||||
// PUT: api/DropZone/5
|
||||
[HttpPut("{id}")]
|
||||
public void Put(int id, [FromBody] DropZoneReq value)
|
||||
{
|
||||
_dropZoneService.UpdateDz(id, _mapper.Map<DropZone>(value));
|
||||
}
|
||||
|
||||
// DELETE: api/ApiWithActions/5
|
||||
[HttpDelete("{id}")]
|
||||
public void Delete(int id)
|
||||
{
|
||||
_dropZoneService.DeleteDzById(id);
|
||||
}
|
||||
|
||||
private readonly IDropZoneService _dropZoneService;
|
||||
private readonly IMapper _mapper;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user