using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Cors; using AutoMapper; using skydiveLogs_api.Business.Interface; using skydiveLogs_api.DataContract; using skydiveLogs_api.Model; namespace skydiveLogs_api.Controllers { public class DropZoneController : Base { public DropZoneController(IDropZoneService dropZoneService, IMapper mapper) { _dropZoneService = dropZoneService; _mapper = mapper; } // GET: api/DropZone [HttpGet] [EnableCors] public IEnumerable Get() { var result = _dropZoneService.GetAllDzs(); return _mapper.Map>(result); } // GET: api/DropZone/5 [HttpGet("{id}")] [EnableCors] public DropZoneResp Get(int id) { var result = _dropZoneService.GetDzById(id); return _mapper.Map(result); } // POST: api/DropZone [HttpPost] [EnableCors] public void Post([FromBody] DropZoneReq value) { _dropZoneService.AddNewDz(_mapper.Map(value)); } // PUT: api/DropZone/5 [HttpPut("{id}")] [EnableCors] public bool Put(int id, [FromBody] DropZoneReq value) { return _dropZoneService.UpdateDz(id, _mapper.Map(value)); } // DELETE: api/ApiWithActions/5 [HttpDelete("{id}")] [EnableCors] public void Delete(int id) { _dropZoneService.DeleteDzById(id); } private readonly IDropZoneService _dropZoneService; private readonly IMapper _mapper; } }