97 lines
2.4 KiB
C#
97 lines
2.4 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Cors;
|
|
|
|
using AutoMapper;
|
|
|
|
using skydiveLogs_api.Domain;
|
|
using skydiveLogs_api.DomainBusiness.Interfaces;
|
|
using skydiveLogs_api.DataContract;
|
|
|
|
namespace skydiveLogs_api.Controllers
|
|
{
|
|
public class DropZoneController : Base
|
|
{
|
|
#region Public Constructors
|
|
|
|
public DropZoneController(IDropZoneService dropZoneService,
|
|
IMapper mapper)
|
|
{
|
|
_dropZoneService = dropZoneService;
|
|
_mapper = mapper;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
// PUT: api/DropZone/AddToFavorite/5
|
|
[HttpPut("AddToFavorite/{id}")]
|
|
[EnableCors]
|
|
public bool AddToFavorite(int id)
|
|
{
|
|
return _dropZoneService.AddToFavorite(id);
|
|
}
|
|
|
|
// DELETE: api/ApiWithActions
|
|
[HttpDelete("{id}")]
|
|
[EnableCors]
|
|
public void Delete(int id)
|
|
{
|
|
_dropZoneService.DeleteDzById(id);
|
|
}
|
|
|
|
// GET: api/DropZone
|
|
[HttpGet]
|
|
[EnableCors]
|
|
public IEnumerable<DropZoneResp> Get()
|
|
{
|
|
var result = _dropZoneService.GetAllDzs();
|
|
|
|
return _mapper.Map<IEnumerable<DropZoneResp>>(result);
|
|
}
|
|
|
|
// GET: api/DropZone/5
|
|
[HttpGet("{id}")]
|
|
[EnableCors]
|
|
public DropZoneResp Get(int id)
|
|
{
|
|
var result = _dropZoneService.GetDzById(id);
|
|
|
|
return _mapper.Map<DropZoneResp>(result);
|
|
}
|
|
|
|
// POST: api/DropZone
|
|
[HttpPost]
|
|
[EnableCors]
|
|
public void Post([FromBody] DropZoneReq value)
|
|
{
|
|
_dropZoneService.AddNewDz(_mapper.Map<DropZone>(value));
|
|
}
|
|
|
|
// PUT: api/DropZone/5
|
|
[HttpPut("{id}")]
|
|
[EnableCors]
|
|
public bool Put(int id, [FromBody] DropZoneReq value)
|
|
{
|
|
return _dropZoneService.UpdateDz(id, _mapper.Map<DropZone>(value));
|
|
}
|
|
|
|
// PUT: api/DropZone/RemoveToFavorite/15
|
|
[HttpPut("RemoveToFavorite/{id}")]
|
|
[EnableCors]
|
|
public bool RemoveToFavorite(int id)
|
|
{
|
|
return _dropZoneService.RemoveToFavorite(id);
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private readonly IDropZoneService _dropZoneService;
|
|
private readonly IMapper _mapper;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |