Skip to content

Instantly share code, notes, and snippets.

@joecastelo
Created September 1, 2020 17:30
Show Gist options
  • Save joecastelo/451bc1672056aae1b390fd8c5a463093 to your computer and use it in GitHub Desktop.
Save joecastelo/451bc1672056aae1b390fd8c5a463093 to your computer and use it in GitHub Desktop.
Structure Id Checking 👽
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VMS.TPS.Common.Model.API;
namespace StructureOnWPF
{
public class Helpers
{
public static string CheckStructureIds(StructureSet ss, string wantedId)
{
var maxLength = 16;
if (ss.Structures.Any(e=>e.Id.ToLower() == wantedId.ToLower()))
{
wantedId = limitChars(new Random().Next(0, 9).ToString() + "_" + wantedId, maxLength);
}
return wantedId;
}
public static string limitChars(string wantedId, int maxLength)
{
return wantedId.Length <= maxLength ? wantedId : wantedId.Substring(0, maxLength);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment