public async Task <IActionResult> PostRoute([FromBody] Route route) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await _routeService.AddRouteAsync(route); } catch (DbUpdateException) { return(BadRequest("Route object is incomplete or contains wrong data.")); } var routeDto = _mapper.Map <Route, RoutesRouteDto>(route); return(CreatedAtAction("GetRoute", new { id = routeDto.Id }, routeDto)); }
public async Task ExecuteAsync() { _routeModel.Id = await _routeService.AddRouteAsync(_routeModel); }