예제 #1
0
        public async Task <IActionResult> Create([FromBody] PlaneModel plane)
        {
            var result = await _planeService.Create(plane);

            if (result == Guid.Empty)
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
예제 #2
0
        public IActionResult Post([FromBody] PlaneModel value)
        {
            var validationResult = _planeModelValidator.Validate(value);

            if (!validationResult.IsValid)
            {
                throw new BadRequestException(validationResult.Errors);
            }

            var entity = _planeService.Create(value);

            return(Json(entity));
        }
        public async Task <IActionResult> Create([FromBody] PlaneDto plane)
        {
            if (ModelState.IsValid)
            {
                await _service.Create(plane);

                return(Ok(plane));
            }
            else
            {
                return(new BadRequestObjectResult(ModelState));
            }
        }
예제 #4
0
 public IActionResult Post([FromBody] PlaneDto value)
 {
     try
     {
         return(Ok(service.Create(value)));
     }
     catch (ValidationException e)
     {
         return(BadRequest(e.Message));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }