public async Task UniqueHash(BellumGensDbContext context) { if (string.IsNullOrEmpty(Hash)) { Hash = Util.GenerateHashString(8); while (await context.TournamentApplications.Where(t => t.Hash == Hash).SingleOrDefaultAsync() != null) { Hash = Util.GenerateHashString(8); } } }
public void UniqueCustomUrl(BellumGensDbContext context) { if (string.IsNullOrEmpty(CustomUrl)) { var parts = Title.Split(' '); string url = string.Join("-", parts); while (context.CSGOStrategies.Where(s => s.CustomUrl == url).SingleOrDefault() != null) { if (url.Length > 58) url = url.Substring(0, 58); url += '-' + Util.GenerateHashString(6); } CustomUrl = url; } }