Esempio n. 1
0
 public void Post([FromBody] AirplaneDTO airplane)
 {
     if (ModelState.IsValid)
     {
         service.Create(airplane);
     }
 }
        public async Task <ActionResult <AirplaneViewModel> > Post(AirplaneViewModel airplane)
        {
            var response = await _airplaneService.Create(airplane.ToModel());

            if (response != BusinessLogic.Enums.StatusCode.Created)
            {
                _logger.LogError($"Airplane {airplane.Name} not Created.");
            }

            return(response == BusinessLogic.Enums.StatusCode.Created
                ? (ActionResult <AirplaneViewModel>)Ok()
                : Conflict());
        }
Esempio n. 3
0
        public async Task <IActionResult> Post([FromBody] AirplaneDTO modelDTO)
        {
            if (modelDTO == null)
            {
                ModelState.AddModelError("", "Plane structure is wrong!!!");
                return(BadRequest(ModelState));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await service.Create(modelDTO);

            return(Created("api/Airplanes", modelDTO));
        }