Beispiel #1
0
        internal static PropertyVm AreaCaption(this MeasureBoundary <int, Area> livingSpace)
        {
            PropertyVm propertyVm = new PropertyVm();

            if (livingSpace != null && (livingSpace.Min.HasValue || livingSpace.Max.HasValue))
            {
                propertyVm.Unit = livingSpace.Measure.GetEnumLocalizedValue <Area>();
                if (!livingSpace.Min.HasValue || !livingSpace.Max.HasValue || livingSpace.Min.Value == livingSpace.Max.Value || livingSpace.Min.Value == 0 || livingSpace.Max.Value == 0)
                {
                    decimal num = (livingSpace.Min.HasValue ? livingSpace.Min.Value : livingSpace.Max.Value);
                    if (num != decimal.Zero)
                    {
                        decimal num1 = Math.Round(num);
                        propertyVm.Value = string.Format("{0}", num1.ToString(ConfigurationManager.Instance.NumberFormat));
                    }
                }
                else
                {
                    int    value = livingSpace.Min.Value;
                    string str   = value.ToString(ConfigurationManager.Instance.NumberFormat);
                    value            = livingSpace.Max.Value;
                    propertyVm.Value = string.Format("{0} - {1}", str, value.ToString(ConfigurationManager.Instance.NumberFormat));
                }
            }
            return(propertyVm);
        }
Beispiel #2
0
 internal static MeasureBoundaryVm <T, M> MapToMeasureBoundaryVm <T, M>(this MeasureBoundary <T, M> measureBoundary)
     where T : struct
     where M : struct
 {
     return(new MeasureBoundaryVm <T, M>()
     {
         Min = measureBoundary.Min,
         Max = measureBoundary.Max,
         Measure = measureBoundary.Measure
     });
 }
Beispiel #3
0
        public static string GetLivingSpace(MeasureBoundary <int, LivingSpaceMeasure> livingSpace)
        {
            if (!livingSpace.Min.HasValue && !livingSpace.Max.HasValue)
            {
                return(null);
            }
            string measure = livingSpace.Measure.GetEnumLocalizedValue <LivingSpaceMeasure>();

            if (livingSpace.Min.HasValue && livingSpace.Max.HasValue)
            {
                int    value = livingSpace.Min.Value;
                string str   = value.ToString(ConfigurationManager.Instance.NumberFormat);
                value = livingSpace.Max.Value;
                return(string.Format("{0} - {1} {2}", str, value.ToString(ConfigurationManager.Instance.NumberFormat), measure));
            }
            decimal num = Math.Round((livingSpace.Min.HasValue ? livingSpace.Min.Value : livingSpace.Max.Value));

            return(string.Format("{0} {1}", num.ToString(ConfigurationManager.Instance.NumberFormat), measure));
        }
Beispiel #4
0
        public static string GetPriceRange(MeasureBoundary <decimal, MoneyType> priceRange)
        {
            decimal num;

            if (!priceRange.Min.HasValue && !priceRange.Max.HasValue)
            {
                return(null);
            }
            string currency = priceRange.Measure.GetEnumLocalizedValue <MoneyType>();

            if (priceRange.Min.HasValue && priceRange.Max.HasValue)
            {
                decimal?min = priceRange.Min;
                num = Math.Round(min.Value);
                string str = num.ToString(ConfigurationManager.Instance.NumberFormat);
                min = priceRange.Max;
                num = Math.Round(min.Value);
                return(string.Format("{0}{1} - {0}{2}", currency, str, num.ToString(ConfigurationManager.Instance.NumberFormat)));
            }
            num = Math.Round((priceRange.Min.HasValue ? priceRange.Min.Value : priceRange.Max.Value));
            return(string.Format("{0}{1}", currency, num.ToString(ConfigurationManager.Instance.NumberFormat)));
        }
Beispiel #5
0
        internal static string PriceCaption(this MeasureBoundary <decimal, Currency> price, string phone)
        {
            decimal num;
            string  empty = string.Empty;

            if (price != null)
            {
                if (!price.Min.HasValue && !price.Max.HasValue)
                {
                    if (!phone.IsNullOrEmpty())
                    {
                        empty = string.Format("Call {0} for rates", phone);
                    }
                    return(empty);
                }
                string enumLocalizedValue = price.Measure.GetEnumLocalizedValue <Currency>();
                if (!price.Min.HasValue || !price.Max.HasValue || !(price.Min.Value != price.Max.Value) || !(price.Min.Value != decimal.Zero) || !(price.Max.Value != decimal.Zero))
                {
                    decimal num1 = (price.Min.HasValue ? price.Min.Value : price.Max.Value);
                    if (num1 != decimal.Zero)
                    {
                        num   = Math.Round(num1);
                        empty = string.Format("{0}{1}", enumLocalizedValue, num.ToString(ConfigurationManager.Instance.NumberFormat));
                    }
                }
                else
                {
                    decimal?min = price.Min;
                    num = Math.Round(min.Value);
                    string str = num.ToString(ConfigurationManager.Instance.NumberFormat);
                    min   = price.Max;
                    num   = Math.Round(min.Value);
                    empty = string.Format("{0}{1} - {0}{2}", enumLocalizedValue, str, num.ToString(ConfigurationManager.Instance.NumberFormat));
                }
            }
            return(empty);
        }
Beispiel #6
0
 internal static string PriceCaption(this MeasureBoundary <decimal, Currency> price)
 {
     return(price.PriceCaption(string.Empty));
 }