mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-05-18 19:48:23 +00:00
c8689e3bba
Tested what I can until more data for the Amazon Ledger Detail table comes in
70 lines
1.7 KiB
C#
70 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace bnhtrade.Core.Logic.Validate
|
|
{
|
|
public static class Format
|
|
{
|
|
/// <summary>
|
|
/// Validates that an sku number string is the correct format i.e. 000000-00
|
|
/// </summary>
|
|
/// <param name="skuNumber"></param>
|
|
/// <returns></returns>
|
|
public static bool SkuNumber(string skuNumber)
|
|
{
|
|
if (string.IsNullOrEmpty(skuNumber))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int count = 0;
|
|
foreach (char c in skuNumber)
|
|
{
|
|
count++;
|
|
if (count == 7)
|
|
{
|
|
string hyphen = "-";
|
|
if (c != hyphen[0])
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
else if (count > 9)
|
|
{
|
|
return false;
|
|
}
|
|
else if (!char.IsNumber(c))
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
count = 0;
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks the datetime is not default and is utc
|
|
/// </summary>
|
|
/// <param name="c"></param>
|
|
/// <returns></returns>
|
|
public static bool DateTime(DateTime dateTime)
|
|
{
|
|
if (dateTime == default(DateTime))
|
|
{
|
|
return false;
|
|
}
|
|
else if (dateTime.Kind != DateTimeKind.Utc)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|