コード例 #1
0
        public async Task <IActionResult> AddPilot([FromBody] PilotDTO pilot)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest() as IActionResult);
            }

            var entity = await service.HirePilotAsync(mapper.Map <Pilot>(pilot));

            return(entity == null?StatusCode(409) as IActionResult
                   : Created($"{Request?.Scheme}://{Request?.Host}{Request?.Path}{entity.Id}",
                             mapper.Map <PilotDTO>(entity)));
        }