public IActionResult AddPlane([FromBody] Plane plane) { if (!ModelState.IsValid) { return(BadRequest() as IActionResult); } var entity = service.AddPlane(plane); return(entity == null?StatusCode(409) as IActionResult : Created($"{Request.Scheme}://{Request.Host}{Request.Path}{entity.Id}", entity)); }
public IActionResult AddPlane([FromBody] PlaneDTO plane) { if (!ModelState.IsValid) { return(BadRequest() as IActionResult); } if (!plane.PlaneTypeId.HasValue) { return(BadRequest("Plane type have to be defined!") as IActionResult); } //var targetType = service.GetPlaneTypeInfo(plane.PlaneTypeId.Value); //if (targetType == null) // return NotFound($"Plane type with id = {plane.PlaneTypeId} not found!Plane not added!"); //var newPlane = mapper.Map<Plane>(plane); //newPlane.Type = targetType; var entity = service.AddPlane(mapper.Map <Plane>(plane)); return(entity == null?StatusCode(409) as IActionResult : Created($"{Request?.Scheme}://{Request?.Host}{Request?.Path}{entity.Id}", mapper.Map <PlaneDTO>(entity))); }