예제 #1
0
 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 }));
     }
 }
예제 #2
0
        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));
        }