public async Task <IActionResult> PostUserZone([FromRoute] User user, [FromBody] Zone Zone) { try { return(Ok(await _context.CreateZoneAsync(Zone, user))); } catch (ArgumentException e) { return(BadRequest(new { error = e.Message })); } }
public async Task <ActionResult> PostAsync([FromBody] Zone zone) { if (zone is null) { return(BadRequest()); } var result = await _zoneService.CreateZoneAsync(zone); if (!result) { return(NotFound()); } return(CreatedAtAction(nameof(GetAsync), new { id = zone.Id }, zone)); }