68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
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
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class DropZoneController : ControllerBase
|
|
{
|
|
public DropZoneController(IDropZoneService dropZoneService,
|
|
IMapper mapper)
|
|
{
|
|
_dropZoneService = dropZoneService;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
// GET: api/DropZone
|
|
[HttpGet]
|
|
public IEnumerable<DropZoneResp> Get()
|
|
{
|
|
var result = _dropZoneService.GetAllDzs();
|
|
|
|
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
|
}
|
|
|
|
// GET: api/DropZone/5
|
|
[HttpGet("{id}")]
|
|
public DropZoneResp Get(int id)
|
|
{
|
|
var result = _dropZoneService.GetDzById(id);
|
|
|
|
return _mapper.Map<DropZoneResp>(result);
|
|
}
|
|
|
|
// 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;
|
|
}
|
|
}
|