Добавлен справочник ResponseArea

This commit is contained in:
Mikhail Kuznetsov
2023-09-28 14:28:10 +10:00
parent 90c500482a
commit 7091e849a4
17 changed files with 3775 additions and 42 deletions

View File

@@ -0,0 +1,27 @@
using AutoMapper;
using PARR.DAL.Contracts;
using PARR.DAL.Models;
using PARR.DAL.Models.AIHIT;
using System.Text.RegularExpressions;
namespace PARR.AIHIT.MappingProfiles.Resolvers
{
internal class ResponseAreaCodeResolver : IValueResolver<RawDataEK, Host, int>
{
public int Resolve(RawDataEK source, Host destination, int destMember, ResolutionContext context)
{
var pattern = "\\d+";
var regex = new Regex(pattern);
int.TryParse(regex.Match(source.ResponseArea!).Value, out int result);
if (result == 0)
return (int)ResponseAreaEnum.gvc;
if (!Enum.IsDefined(typeof(ResponseAreaEnum), result))
throw new Exception($"Неверный код дороги {source.ResponseArea}");
return result;
}
}
}