public ActionResult <RContinentOut> PostContinent([FromBody] RContinentIn rContinentIn) { try { Continent toAdd = Mapper.FromRContinentInToContinent(rContinentIn); Continent toReturn = dc.AddContinent(toAdd); return(CreatedAtAction(nameof(GetContinent), new { id = toReturn.Id }, Mapper.FromContinentToRContinentOut(toReturn, apiUrl))); } catch (Exception ex) { return(NotFound(ex.Message)); } }
public ActionResult <RContinentOut> PutContinent(int id, [FromBody] RContinentIn rContinentIn) { try { if (dc.IsInContinents(id)) { Continent updatedContinent = dc.UpdateContinent(id, Mapper.FromRContinentInToContinent(rContinentIn)); return(Ok(Mapper.FromContinentToRContinentOut(updatedContinent, apiUrl))); } Continent addedContinent = dc.AddContinent(Mapper.FromRContinentInToContinent(rContinentIn)); return(CreatedAtAction(nameof(GetContinent), new { id = id }, Mapper.FromContinentToRContinentOut(addedContinent, apiUrl))); } catch (Exception ex) { return(NotFound(ex.Message)); } }