コード例 #1
0
 internal static GM.Currency_Exchange ToGlobal(this Currency_Exchange curx)
 {
     return(new GM.Currency_Exchange()
     {
         Id = curx.Id, CurrFrom = curx.CurrFrom, CurrTo = curx.CurrTo, DateFrom = curx.DateFrom, DateTo = curx.DateTo, Rate = curx.Rate
     });
 }
コード例 #2
0
        public IActionResult ChkCurrXDtF([FromBody] Currency_Exchange x)
        {
            try
            {
                if (x is null)
                {
                    throw new ArgumentNullException("Currency Exchange Object Empty (" + where + ") (CF)");
                }
                if (x.CurrFrom.Length == 3)
                {
                    throw new DataException("Currency From must be 3 digits (" + where + ") (CF)");
                }
                if (x.CurrTo.Length == 3)
                {
                    throw new DataException("Currency To must be 3 digits (" + where + ") (CF)");
                }

                int RcdCntFrom = S.ServiceLocator.Instance.Currency_ExchangeService.Check_DateF(new SM.Currency_Exchange(0, x.CurrFrom, x.CurrTo, x.DateFrom, x.DateTo, x.Rate));
                return(ApiControllerHelper.SendOk(this, new ApiResult <int>(HttpStatusCode.OK, null, RcdCntFrom), HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
コード例 #3
0
        public IActionResult Add([FromBody] Currency_Exchange x)
        {
            try
            {
                if (x is null)
                {
                    throw new ArgumentNullException("Currency Exchange Object Empty (" + where + ") (ADD)");
                }
                if (x.CurrFrom.Length != 3)
                {
                    throw new DataException("Currency From must be 3 digits (" + where + ") (ADD)");
                }
                if (x.CurrTo.Length != 3)
                {
                    throw new DataException("Currency To must be 3 digits (" + where + ") (ADD)");
                }
                if (x.DateFrom > x.DateTo)
                {
                    throw new DataException("Date From Bigger than Date To (" + where + ") (ADD)");
                }

                S.ServiceLocator.Instance.Currency_ExchangeService.Add(new SM.Currency_Exchange(0, x.CurrFrom, x.CurrTo, x.DateFrom, x.DateTo, x.Rate));
                return(ApiControllerHelper.SendOk(this));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
コード例 #4
0
        public IActionResult Upd(int id, [FromBody] Currency_Exchange x)
        {
            try
            {
                if (id < 1)
                {
                    throw new IndexOutOfRangeException("ID must be greater than 0 (" + where + ") (UPD)");
                }
                if (x is null)
                {
                    throw new ArgumentNullException("Currency Exchange Object Empty (" + where + ") (UPD)");
                }
                if (x.CurrFrom.Length != 3)
                {
                    throw new DataException("Currency From must be 3 digits (" + where + ") (UPD)");
                }
                if (x.CurrTo.Length != 3)
                {
                    throw new DataException("Currency To must be 3 digits (" + where + ") (UPD)");
                }
                if (x.DateFrom > x.DateTo)
                {
                    throw new DataException("Date From Bigger than Date To (" + where + ") (UPD)");
                }

                bool UpdOk = S.ServiceLocator.Instance.Currency_ExchangeService.Upd(new SM.Currency_Exchange(id, x.CurrFrom, x.CurrTo, x.DateFrom, x.DateTo, x.Rate));
                return(ApiControllerHelper.SendOk(this, new ApiResult <bool>(HttpStatusCode.OK, null, UpdOk), HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }