This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using AyaNova.Util;
|
||||
using System.Linq;
|
||||
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
public static class TagUtil
|
||||
{
|
||||
//clean up tags from client submission
|
||||
//remove dupes, substitute dashes for spaces, lowercase and shorten if exceed 255 chars
|
||||
public static List<string> NormalizeTags(List<string> inTags)
|
||||
{
|
||||
if (inTags==null || inTags.Count == 0) return inTags;
|
||||
@@ -15,7 +18,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
outTags.Add(NormalizeTag(tag));
|
||||
}
|
||||
return outTags;
|
||||
return outTags.Distinct().ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace AyaNova.Util
|
||||
{
|
||||
get
|
||||
{
|
||||
return "8.0.0-alpha.2018.10.11";
|
||||
return "8.0.0-alpha.2018.12.07";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace AyaNova.Util
|
||||
SeedDatabase(slevel, Guid.Empty);
|
||||
}
|
||||
|
||||
|
||||
public static void SeedDatabase(SeedLevel slevel, Guid JobId)
|
||||
{
|
||||
bool LogJob = JobId != Guid.Empty;
|
||||
@@ -297,6 +298,15 @@ namespace AyaNova.Util
|
||||
}
|
||||
|
||||
|
||||
private static string[] TagSet = new[] { "red", "orange", "yellow", "green", "blue", "indigo", "violet", "brown", "black", "white", "silver", "gold" };
|
||||
|
||||
private static List<string> RandomTags(Faker f)
|
||||
{
|
||||
|
||||
var t = f.PickRandom(TagSet, f.Random.Int(1, TagSet.Length));
|
||||
return new List<string>(t);
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////
|
||||
//Seed test data for integration tests
|
||||
//
|
||||
@@ -379,6 +389,8 @@ namespace AyaNova.Util
|
||||
//allow creation of not entirely ready users (missing client id or subcontractor vendor id etc)
|
||||
Biz.SeedOrImportRelaxedRulesMode = true;
|
||||
|
||||
Faker Fake = new Faker();
|
||||
|
||||
for (int x = 0; x < count; x++)
|
||||
{
|
||||
User u = new User();
|
||||
@@ -402,7 +414,7 @@ namespace AyaNova.Util
|
||||
u.LocaleId = localeId == 0 ? ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID : localeId;
|
||||
u.UserType = userType;
|
||||
//TODO: After have USER and HEADOFFICE and VENDOR, if usertype is subcontractor or client or headoffice it needs to set a corresponding user's parent org record id to go with it
|
||||
|
||||
u.Tags = RandomTags(Fake);
|
||||
//Children and relations
|
||||
u.UserOptions = new UserOptions(1);
|
||||
u.UserOptions.EmailAddress = p.Email.Replace("gmail.com", "helloayanova.com").Replace("hotmail.com", "helloayanova.com").Replace("yahoo.com", "helloayanova.com");
|
||||
@@ -435,6 +447,7 @@ namespace AyaNova.Util
|
||||
//this is nonsense but just to test an enum
|
||||
o.Roles = AuthorizationRoles.DispatchLimited | AuthorizationRoles.InventoryLimited | AuthorizationRoles.OpsAdminLimited;
|
||||
o.Notes = f.Lorem.Paragraph();
|
||||
o.Tags = RandomTags(f);
|
||||
var NewObject = Biz.Create(ServiceProviderProvider.DBContext, o);
|
||||
if (NewObject == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user