Files
bnhtrade/src/bnhtrade.Core/Logic/Validate/Format.cs
T
Bobbie Hodgetts c8689e3bba Amazon inventory ledger testing and implementation
Tested what I can until more data for the Amazon Ledger Detail table comes in
2024-11-21 17:50:18 +00:00

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;
}
}
}
}