private void InitializeModifierFilter <T>(PriceFilterCategory category, string id, string label, T value, double delta = 5, bool enabled = false, double?min = null, double?max = null, bool normalizeValues = true) { ModifierOption option = null; if (value is List <double> groupValue) { var itemValue = groupValue.OrderBy(x => x).FirstOrDefault(); if (itemValue >= 0) { min = itemValue; if (normalizeValues) { min = NormalizeMinValue(min, delta); } } else { max = itemValue; if (normalizeValues) { max = NormalizeMaxValue(max, delta); } } if (!groupValue.Any()) { min = null; max = null; } } var priceFilter = new PriceFilter() { Enabled = enabled, PropertyType = null, Id = id, Text = label, Min = min, Max = max, HasRange = min.HasValue || max.HasValue, Option = option, }; priceFilter.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { UpdateDebounce(); }; category.Filters.Add(priceFilter); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='value'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task PostAsync(this IModifierOptionOperations operations, string locationId, string modifierListId, ModifierOption value, CancellationToken cancellationToken = default(CancellationToken)) { await operations.PostWithHttpMessagesAsync(locationId, modifierListId, value, null, cancellationToken).ConfigureAwait(false); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='value'> /// </param> public static void Post(this IModifierOptionOperations operations, string locationId, string modifierListId, ModifierOption value) { Task.Factory.StartNew(s => ((IModifierOptionOperations)s).PostAsync(locationId, modifierListId, value), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public Task <HttpOperationResponse <ModifierOption> > PutWithHttpMessagesAsync(string locationId, string modifierListId, string id, ModifierOption value, Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) { var uri = GetUri(locationId, modifierListId).Append(id); return(PutWithHttpMessagesAsync(uri, value, customHeaders, cancellationToken)); }
private void InitializeFilter <T>(PriceFilterCategory category, string type, string id, string label, T value, double delta = 5, bool enabled = false, double?min = null, double?max = null, bool alwaysIncluded = false, bool normalizeValues = true, bool applyNegative = false) { ModifierOption option = null; if (value is bool boolValue) { if (!boolValue && !alwaysIncluded) { return; } } else if (value is int intValue) { if (intValue == 0 && !alwaysIncluded) { return; } if (min == null && normalizeValues) { min = NormalizeMinValue(intValue, delta); } if (LabelValues.IsMatch(label)) { label = LabelValues.Replace(label, intValue.ToString()); } else { label += $": {value}"; } } else if (value is double doubleValue) { if (doubleValue == 0 && !alwaysIncluded) { return; } if (min == null && normalizeValues) { min = NormalizeMinValue(doubleValue, delta); } if (LabelValues.IsMatch(label)) { label = LabelValues.Replace(label, doubleValue.ToString("0.00")); } else { label += $": {doubleValue:0.00}"; } } else if (value is List <double> groupValue) { var itemValue = groupValue.OrderBy(x => x).FirstOrDefault(); if (itemValue >= 0) { min = itemValue; if (normalizeValues) { min = NormalizeMinValue(min, delta); } } else { max = itemValue; if (normalizeValues) { max = NormalizeMaxValue(max, delta); } } if (!groupValue.Any()) { min = null; max = null; } } else if (value is ModifierOption modifierOption) { option = modifierOption; min = null; max = null; } var priceFilter = new PriceFilter() { Enabled = enabled, Type = type, Id = id, Text = label, Min = min, Max = max, HasRange = min.HasValue || max.HasValue, ApplyNegative = applyNegative, Option = option, }; priceFilter.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { UpdateDebounce(); }; category.Filters.Add(priceFilter); }