0
0

Add elobow modifier

This commit is contained in:
Serghei Cebotari 2023-10-03 21:58:17 +03:00
parent 28f85e5c9d
commit f1d196da91
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,36 @@
using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Http.Extensions;
namespace RhSolutions.Api.Services
{
public class ElbowModifier : IProductQueryModifier
{
private string diameterPattern { get; } = @"\b(16|20|25|32|40|50|63)\b";
private string anglePattern { get; } = @"\b(45|90)";
public bool TryQueryModify(IQueryCollection collection, out QueryString queryString)
{
queryString = QueryString.Empty;
var query = collection["query"].ToString();
if (string.IsNullOrEmpty(query))
{
return false;
}
var diameter = Regex.Match(query, diameterPattern);
if (diameter.Success)
{
var angle = Regex.Match(query, anglePattern);
QueryBuilder qb = new()
{
{"query", $"Угольник RAUTITAN -PLATINUM {(angle.Success ? angle.Captures.First() : 90)} {diameter.Captures.First()}"}
};
queryString = qb.ToQueryString();
return true;
}
else
{
return false;
}
}
}
}

View File

@ -18,6 +18,8 @@ public class ProductQueryModifierFactory
return new AdapterScrewcapModifier(); return new AdapterScrewcapModifier();
case "Муфта соединительная": case "Муфта соединительная":
return new CouplingModifier(); return new CouplingModifier();
case "Угольник RAUTITAN":
return new ElbowModifier();
case "Flex": case "Flex":
return new FlexPipeQueryModifier(); return new FlexPipeQueryModifier();
case "Stabil": case "Stabil":