summaryrefslogtreecommitdiff
path: root/RhSolutions.QueryModifiers/CouplingModifier.cs
diff options
context:
space:
mode:
Diffstat (limited to 'RhSolutions.QueryModifiers/CouplingModifier.cs')
-rw-r--r--RhSolutions.QueryModifiers/CouplingModifier.cs38
1 files changed, 0 insertions, 38 deletions
diff --git a/RhSolutions.QueryModifiers/CouplingModifier.cs b/RhSolutions.QueryModifiers/CouplingModifier.cs
deleted file mode 100644
index e8a1739..0000000
--- a/RhSolutions.QueryModifiers/CouplingModifier.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System.Text.RegularExpressions;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Http.Extensions;
-
-namespace RhSolutions.QueryModifiers;
-
-public class CouplingModifier : IProductQueryModifier
-{
- private string pattern { get; } = @"([\b\D]|^)?(?<Diameter>16|20|25|32|40|50|63)([\b\D]|$)?";
- public bool TryQueryModify(IQueryCollection collection, out QueryString queryString)
- {
- queryString = QueryString.Empty;
- var query = collection["query"].ToString();
- if (string.IsNullOrEmpty(query))
- {
- return false;
- }
- var matches = Regex.Matches(query, pattern);
- if (matches.Count < 1)
- {
- return false;
- }
- else
- {
- QueryBuilder qb = new();
- if (matches.Count < 2 || matches.Count > 1 && matches[0].Groups["Diameter"].Value == matches[1].Groups["Diameter"].Value)
- {
- qb.Add("query", $"Муфта соединительная равнопроходная {matches[0].Groups["Diameter"].Value}");
- }
- else
- {
- qb.Add("query", $"Муфта соединительная переходная {matches[0].Groups["Diameter"].Value}-{matches[1].Groups["Diameter"].Value}");
- }
- queryString = qb.ToQueryString();
- return true;
- }
- }
-}