Exemplo n.º 1
0
        /// <summary>
        /// It shows the customer variables values
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public string GetPackagePricingDetails(int packageID, int pricingEstimateID, int pricingEstimateRevision)
        {
            var pv = PricingVariables.FromPricingEstimatePackage(packageID, pricingEstimateID, pricingEstimateRevision);

            return(pv == null ? ""
                : String.Format("bedrooms: {0}, bathrooms: {1}", pv.GetValue <int>("BedsNumber", 0), pv.GetValue <int>("BathsNumber", 0)));
        }
        /// <summary>
        /// It shows the customer variables values
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public string GetPackagePricingDetails(int packageID, int pricingEstimateID, int pricingEstimateRevision)
        {
            var pv            = PricingVariables.FromPricingEstimatePackage(packageID, pricingEstimateID, pricingEstimateRevision);
            var res           = new List <string>();
            var summaryFormat = "{0}: {1}";

            foreach (var v in pv)
            {
                // On pricing summary only customer values are showed,
                // and the special var 'Hours' is avoided since the package already shows its 'total duration'
                // as part of the generic information
                if (v.Value.Def.IsProviderVariable ||
                    v.Key == "Hours")
                {
                    continue;
                }

                // If value is a number
                var val = v.Value.GetValue <double?>(null);
                if (val.HasValue)
                {
                    // Show singular or plural depending on the value
                    if (val.Value == 1)
                    {
                        res.Add(String.Format(summaryFormat, v.Value.Def.VariableNameSingular, 1));
                    }
                    else
                    {
                        res.Add(String.Format(summaryFormat, v.Value.Def.VariableNamePlural, val.Value));
                    }
                }
                else
                {
                    // Is another kind of value (string, datetime, ...) use singular variable name
                    res.Add(String.Format(summaryFormat, v.Value.Def.VariableNameSingular, v.Value.Value));
                }
            }
            return(ASP.LcHelpers.JoinNotEmptyStrings(", ", res));
        }