Exemplo n.º 1
0
        public async ValueTask <RequestResult <OrderInfo> > OrderGetById(int orderId)
        {
            var result = new RequestResult <OrderInfo>();

            try
            {
                result.RequestData = await _orderStorage.OrderGetById(orderId);

                decimal currencyExchangeRate;
                switch (result.RequestData.Store.City.Id)
                {
                case (int)CityEnum.Minsk:
                    currencyExchangeRate = CurrencyRates.ActualCurrencyRates.Find(item => item.Code == "BYN").Rate;
                    break;

                case (int)CityEnum.Kiev:
                    currencyExchangeRate = CurrencyRates.ActualCurrencyRates.Find(item => item.Code == "UAH").Rate;
                    break;

                default:
                    currencyExchangeRate = 1;
                    break;
                }

                //result.RequestData.Total = Math.Round(result.RequestData.Total / currencyExchangeRate);
                //result.RequestData.Product.Price = Math.Round(result.RequestData.Product.Price / currencyExchangeRate);

                result.IsOkay = true;
            }
            catch (Exception ex)
            {
                result.ExMessage = ex.Message;
            }
            return(result);
        }
Exemplo n.º 2
0
        public async ValueTask <RequestResult <Order> > OrderGetById(int id)
        {
            var result = new RequestResult <Order>();

            try
            {
                result.RequestData = await _storage.OrderGetById(id);

                result.RequestData.OrderItems = await _storage.OrderProductsGetByOrderId((int)result.RequestData.Id);

                result.IsOkay = true;
            }
            catch (Exception ex)
            {
                result.ExMessage = ex.Message;
            }
            return(result);
        }