public IActionResult Add([FromBody] Currency cur) { try { if (cur is null) { throw new ArgumentNullException("Currency Object Empty (" + where + ") (ADD)"); } if (cur.Curr is null) { throw new ArgumentNullException("Currency Curr Empty (" + where + ") (ADD)"); } if (cur.Curr.Length != 3) { throw new IndexOutOfRangeException("Currency must be 3 digits (" + where + ") (ADD)"); } SM.Currency curo = new SM.Currency(cur.Curr, cur.Desc); S.ServiceLocator.Instance.CurrencyService.Add(curo); return(ApiControllerHelper.SendOk(this)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public IActionResult Upd([FromBody] SM.Currency cur) { try { if (cur is null) { throw new ArgumentNullException("Currency Object Empty (" + where + ") (UPD)"); } if (cur.Curr is null) { throw new ArgumentNullException("Currency Curr Empty (" + where + ") (UPD)"); } if (cur.Curr.Length != 3) { throw new IndexOutOfRangeException("Currency must be 3 digits (" + where + ") (UPD)"); } SM.Currency curo = new SM.Currency(cur.Curr, cur.Desc); bool UpdOk = S.ServiceLocator.Instance.CurrencyService.Upd(curo); return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), HttpStatusCode.OK)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public IActionResult Get([FromRoute] string curr) { try { if (curr.Length != 3) { throw new IndexOutOfRangeException("Currency must be 3 digits (" + where + ") (GET)"); } SM.Currency cur = S.ServiceLocator.Instance.CurrencyService.Get(curr); return(ApiControllerHelper.SendOk(this, new ApiResult <SM.Currency>(HttpStatusCode.OK, null, cur), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }