init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
63
Kreta.Core/Logic/BankszamlaLogic.cs
Normal file
63
Kreta.Core/Logic/BankszamlaLogic.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Kreta.Resources;
|
||||
|
||||
namespace Kreta.Core.Logic
|
||||
{
|
||||
public static class BankszamlaLogic
|
||||
{
|
||||
private static readonly int[] s_sulyok = new int[] { 9, 7, 3, 1, 9, 7, 3, 1 };
|
||||
|
||||
public static string KitoltottsegValidacio(string bankszamlaSzam, int? bankszamlaTulajdonosTipusId, string bankszamlaTulajdonosNeve)
|
||||
{
|
||||
var parList = new List<string>()
|
||||
{
|
||||
bankszamlaSzam,
|
||||
bankszamlaTulajdonosTipusId.ToString(),
|
||||
bankszamlaTulajdonosNeve,
|
||||
};
|
||||
if ((parList.All(x => !string.IsNullOrWhiteSpace(x))) || (parList.All(x => string.IsNullOrWhiteSpace(x))))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return ErrorResource.BankszamlaAdatokKitoltottsegeHibas;
|
||||
}
|
||||
|
||||
public static string CDVValidacio(string bankszamlaSzam)
|
||||
{
|
||||
var bankszamlaNonSpace = bankszamlaSzam.Replace(" ", "");
|
||||
var komponensek = bankszamlaNonSpace.Split("-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
if ((!komponensek.Skip(1).Any()) || (komponensek.Skip(3).Any()) || komponensek.Any(x => x.Length < 8))
|
||||
{
|
||||
return ErrorResource.NemMegfeleloSzamuSzamjegyuSzamlaszam;
|
||||
}
|
||||
|
||||
var replBankszamlaSzam = bankszamlaNonSpace.Replace("-", "").Select(x => int.Parse(x.ToString())).ToList();
|
||||
int szumProd = replBankszamlaSzam.Take(8).Select((n, i) => n * s_sulyok[i]).Sum();
|
||||
if ((szumProd % 10) != 0)
|
||||
{
|
||||
return ErrorResource.NemMegfeleloFormatumuElsoOktetSzamlaszamban;
|
||||
}
|
||||
szumProd = replBankszamlaSzam.Select((n, i) => n * s_sulyok[i % 8]).Sum();
|
||||
if ((szumProd % 10) != 0)
|
||||
{
|
||||
return string.Format(ErrorResource.NemMegfeleloFormatumXOktetSzamlaszamban, komponensek.Length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<string> StringSplitByChunkSize(string str, int chunkSize)
|
||||
{
|
||||
return Enumerable.Range(0, str.Length / chunkSize)
|
||||
.Select(i => str.Substring(i * chunkSize, chunkSize)).ToList();
|
||||
}
|
||||
|
||||
public static bool IsBankAccountNumberValid(string bankAccountNumber)
|
||||
{
|
||||
var bankAccountNumberRegex = new Regex(Constants.General.BankAccountNumberRegexPattern);
|
||||
return bankAccountNumberRegex.IsMatch(bankAccountNumber);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue