Exemple #1
0
        /// <summary>Generate a control for a range preference.</summary>
        private static string RangePreferenceControl(HtmlHelper helper, MetaAttribute ma, Preference preference)
        {
            string lowerBoundControl;
            string upperBoundControl;
            string currentLowerBound = null;
            string currentUpperBound = null;

            if (preference != null)
            {
                currentLowerBound = (preference.Range.LowerBound != null) ? preference.Range.LowerBound.Formatted : String.Empty;
                currentUpperBound = (preference.Range.UpperBound != null) ? preference.Range.UpperBound.Formatted : String.Empty;
            }

            if (ma.HasChoices)
            {
                SelectList lowerBoundListData = (preference != null)
                    ? new SelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text", currentLowerBound)
                    : new SelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text");
                SelectList upperBoundListData = (preference != null)
                    ? new SelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text", currentUpperBound)
                    : new SelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text");

                lowerBoundControl = helper.DropDownList(ma.PreferenceLowerBoundHtmlControlName, lowerBoundListData, OPTION_LABEL);
                upperBoundControl = helper.DropDownList(ma.PreferenceUpperBoundHtmlControlName, upperBoundListData, OPTION_LABEL);
            }
            else
            {
                lowerBoundControl = helper.TextBox(ma.PreferenceLowerBoundHtmlControlName, currentLowerBound, new {length=10});
                upperBoundControl = helper.TextBox(ma.PreferenceUpperBoundHtmlControlName, currentUpperBound, new {length=10});
            }

            return String.Format(
                "From {2}{0} to {2}{1}", lowerBoundControl, upperBoundControl, (ma.DataTypeEnum == MetaAttribute.MetaAttributeDataType.CURRENCY) ? "$" : String.Empty);
        }
Exemple #2
0
        /// <summary>Generate a control for a set preference.</summary>
        private static string SetPreferenceControl(HtmlHelper helper, MetaAttribute ma, Preference preference)
        {
            string result;

            if (ma.HasChoices)
            {
                if (preference != null)
                {
                    MultiSelectList listData = new MultiSelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text",
                        SelectHelper.ValuesFromValueSet(preference.Set));
                    result = helper.ListBox(ma.PreferenceSetControlName, listData);
                }
                else
                {
                    MultiSelectList listData = new MultiSelectList(SelectHelper.DropDownRecordsFromValueSet(ma.ChoicesCollection), "Value", "Text");
                    result = helper.ListBox(ma.PreferenceSetControlName, listData);
                }
            }
            else
            {
                if (preference != null)
                {
                    result = helper.TextBox(ma.PreferenceSetControlName, preference.RawValues);
                }
                else
                {
                    result = helper.TextBox(ma.PreferenceSetControlName);
                }
            }
            return result;
        }
 public IEnumerable<Product> FindProductsByFilter(MetaAttribute metaAttribute, string productAttributeRawValue1, IEnumerable<Product> products)
 {
     var templateBuyer = new Buyer();
     var preference = new Preference();
     preference.MetaAttribute = metaAttribute;
     preference.RawValues = productAttributeRawValue1;
     templateBuyer.Preferences.Add(preference);
     return products.Where(product => templateBuyer.IsMatch(product));
 }
Exemple #4
0
 /// <summary>Generate a control for displaying a preference.</summary>
 /// <param name="helper"></param><param name="ma"></param><param name="preference"></param>
 /// <returns></returns>
 public static string PreferenceControl(HtmlHelper helper, MetaAttribute ma, Preference preference)
 {
     switch (ma.SetOrRangeEnum)
     {
         case MetaAttribute.MetaAttributeSetOrRange.SET: return SetPreferenceControl(helper, ma, preference);
         case MetaAttribute.MetaAttributeSetOrRange.RANGE: return RangePreferenceControl(helper, ma, preference);
         default: throw new Exception("Unknown Set or Range " + ma.SetOrRangeEnum.ToString());
     }
 }
 partial void DeletePreference(Preference instance);
 partial void UpdatePreference(Preference instance);
 partial void InsertPreference(Preference instance);
		private void detach_Preferences(Preference entity)
		{
			this.SendPropertyChanging();
			entity.MetaAttribute = null;
		}
		private void detach_Preferences(Preference entity)
		{
			this.SendPropertyChanging();
			entity.Buyer = null;
		}
		private void attach_Preferences(Preference entity)
		{
			this.SendPropertyChanging();
			entity.Buyer = this;
		}