public CurrencyRate Add(CurrencyRateDTO currencyRateDTO)
        {
            CurrencyRate currencyRate = _mapper.Map <CurrencyRate>(currencyRateDTO);

            _currencyRatesRepo.Add(currencyRate);
            return(currencyRate);
        }
Beispiel #2
0
        public CurrencyRate Add(CurrencyRate currencyRate)
        {
            currencyRate.DateOfRate = DateTime.Now;
            CurrencyRate rate = _currencyRatesRepository.Add(currencyRate);

            _productsRepository.UpdatePricesInMainCurrency();

            return(rate);
        }
Beispiel #3
0
        public object Post(CurrencyRate added)
        {
            object json;
            string messageError = "";

            try
            {
                CurrencyRate posted = repository.Add(added, ref messageError);

                if (posted != null)
                {
                    json = new
                    {
                        total   = 1,
                        data    = posted,
                        success = true
                    };
                }
                else
                {
                    json = new
                    {
                        message = messageError,
                        success = false
                    };
                };
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                object error = new { message = ex.Message };

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }