public async Task <ActionResult <AirplaneViewModel> > Add([FromBody] AirplaneViewModel airplaneViewModel) { if (!ModelState.IsValid) { return(CustomReponse(ModelState)); } await _dbAirplane.Add(_mapper.Map <Airplane>(airplaneViewModel)); return(CustomResponse(airplaneViewModel)); }
public ResponseResult <int> Add(AirplaneViewModel model) { using (_unitOfWork) { var map = _mapper.Map <AirplaneModel>(model); var result = _airplaneService.Add(map); if (result.IsValid) { _unitOfWork.Commit(); return(new ResponseResult <int>(result.Data.Id)); } else { return(new ResponseResult <int>(result.ValidationResult)); } } }
public void Insert([FromBody] Airplane airplane) { _service.Add(airplane); }