public IActionResult Get([FromRoute] String iso) { try { if (iso.Length != 2) { throw new IndexOutOfRangeException("Country must be 2 digits (" + where + ") (GET)"); } SM.Country ctry = S.ServiceLocator.Instance.CountryService.Get(iso); return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Country>(HttpStatusCode.OK, null, ctry), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public IActionResult Add([FromBody] Country ctry) { try { if (ctry is null) { throw new ArgumentNullException("Currency Exchange Object Empty (" + where + ") (ADD)"); } if (ctry.ISO.Length != 2) { throw new IndexOutOfRangeException("Country must be 2 digits (" + where + ") (ADD)"); } SM.Country ctryo = new SM.Country(ctry.ISO, ctry.Ctry, ctry.IsEU); S.ServiceLocator.Instance.CountryService.Add(ctryo); return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Country>(HttpStatusCode.OK, null, ctryo), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }