public async Task <IActionResult> Post([FromBody] Station model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var station = _stationService.Add(model); return(CreatedAtAction("Get", new { id = station.Id }, station)); }
public IActionResult Post([FromBody] Station station) { try { return(Ok(_stationService.Add(station).ToApiModel())); } catch (Exception ex) { ModelState.AddModelError("AddStation", ex.Message); return(BadRequest(ModelState)); } }