using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authentication.JwtBearer; using AutoMapper; using skydiveLogs_api.Business.Interface; using skydiveLogs_api.DataContract; using skydiveLogs_api.Model; using System.Linq; using System.Security.Claims; namespace skydiveLogs_api.Controllers { [Route("api/[controller]")] [ApiController] [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] public class JumpController : Base { public JumpController(IJumpService jumpService, IMapper mapper) { _jumpService = jumpService; _mapper = mapper; } // GET: api/Jump [HttpGet] [EnableCors] public IEnumerable Get() { var result = _jumpService.GetAllJumps(ConnectedUser); return _mapper.Map>(result); } // GET: api/Jump/5 [HttpGet("{id}")] [EnableCors] public JumpResp Get(int id) { var result = _jumpService.GetJumpById(id); return _mapper.Map(result); } // POST: api/Jump [HttpPost] [EnableCors] public void Post([FromBody] JumpReq value) { _jumpService.AddNewJump(value.AircraftId, value.DropZoneId, value.JumpTypeId, value.GearId, _mapper.Map(value), ConnectedUser); } // PUT: api/Jump/5 [HttpPut("{id}")] [EnableCors] public void Put(int id, [FromBody] JumpReq value) { _jumpService.UpdateJump(id, _mapper.Map(value)); } // DELETE: api/ApiWithActions/5 [HttpDelete("{id}")] [EnableCors] public void Delete(int id) { _jumpService.DeleteJumpById(id); } private readonly IJumpService _jumpService; private readonly IMapper _mapper; } }