Add elobow modifier
This commit is contained in:
parent
28f85e5c9d
commit
f1d196da91
36
RhSolutions.Api/Services/ElbowModifier.cs
Normal file
36
RhSolutions.Api/Services/ElbowModifier.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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":
|
||||||
|
Loading…
Reference in New Issue
Block a user