Beispiel #1
0
        string MoneyToCurrency(PriceСurrency currency, decimal money)
        {
            if (money == 0)
            {
                return(String.Empty);
            }

            string toCurrency;
            string fromCurrency = currency.ToString();

            if (currencyMode == CurrencyMode.Edit)
            {
                toCurrency = currency.ToString();
            }
            else
            {
                toCurrency = currencyMode.ToString();
            }

            if (fromCurrency.CompareTo(toCurrency) != 0)
            {
                var converted = CurrencyConverter.Convert(money, fromCurrency, toCurrency);
                if (converted == null)
                {
                    return(String.Empty);
                }
                money = converted.Value;
            }

            return(String.Format("{0:N2} {1}",
                                 money, toCurrency));
        }
Beispiel #2
0
        public virtual void AddItem(Fitting fitting, PriceСurrency currency, decimal cost = 0)
        {
            var item = new PriceItem {
                Price    = this,
                Fitting  = fitting,
                Currency = currency,
                Cost     = cost
            };

            ObservablePrices.Add(item);
        }
Beispiel #3
0
        void Dlg_ObjectSelected(object sender, ReferenceRepresentationSelectedEventArgs e)
        {
            var fittings = UoW.GetById <Fitting> (e.GetNodes <FittingVMNode> ().Select(x => x.Id).ToArray());

            PriceСurrency defaulCurr = PriceСurrency.USD;

            if (Entity.Prices.Count > 0)
            {
                defaulCurr = Entity.Prices.GroupBy(x => x.Currency)
                             .Select(g => new {
                    Currency = g.Key,
                    Count    = g.Count(),
                }).OrderByDescending(x => x.Count).First().Currency;
            }

            foreach (var item in e.GetNodes <FittingVMNode>())
            {
                Entity.AddItem(fittings.First(x => x.Id == item.Id), defaulCurr);
            }
        }