diff --git a/server/AyaNova/util/Seeder.cs b/server/AyaNova/util/Seeder.cs index dbdf847c..f83120bf 100644 --- a/server/AyaNova/util/Seeder.cs +++ b/server/AyaNova/util/Seeder.cs @@ -228,7 +228,7 @@ namespace AyaNova.Util await SeedUserAsync(log, 1, AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Inventory | AuthorizationRoles.OpsAdmin, UserType.Service); //Generate one office person / secretary await SeedUserAsync(log, 1, AuthorizationRoles.Service | AuthorizationRoles.Inventory | AuthorizationRoles.Accounting, UserType.NotService); - // await SeedWidgetAsync(log, 3);//keeping this here for now but must remove later + // await SeedWidgetAsync(log, 3);//keeping this here for now but must remove later await SeedCustomerAsync(log, 25); await SeedHeadOfficeAsync(log, 10); await SeedVendorAsync(log, 10); @@ -564,8 +564,8 @@ namespace AyaNova.Util await SeedUserAsync(log, 1, AuthorizationRoles.InventoryRestricted, UserType.NotService, "InventoryRestricted", "InventoryRestricted", KnownUserTags); await SeedUserAsync(log, 1, AuthorizationRoles.Inventory, UserType.NotService, "Inventory", "Inventory", KnownUserTags); await SeedUserAsync(log, 1, AuthorizationRoles.Accounting, UserType.NotService, "Accounting", "Accounting", KnownUserTags); - await SeedUserAsync(log, 1, AuthorizationRoles.TechRestricted, UserType.Service, "TechRestricted", "TechRestricted", KnownUserTags); - await SeedUserAsync(log, 1, AuthorizationRoles.Tech, UserType.Service, "Tech", "Tech", KnownUserTags); + KnownUserTechRestrictedId = await SeedUserAsync(log, 1, AuthorizationRoles.TechRestricted, UserType.Service, "TechRestricted", "TechRestricted", KnownUserTags); + KnownUserTechId = await SeedUserAsync(log, 1, AuthorizationRoles.Tech, UserType.Service, "Tech", "Tech", KnownUserTags); await SeedUserAsync(log, 1, AuthorizationRoles.SalesRestricted, UserType.NotService, "SalesRestricted", "SalesRestricted", KnownUserTags); await SeedUserAsync(log, 1, AuthorizationRoles.Sales, UserType.NotService, "Sales", "Sales", KnownUserTags); @@ -796,8 +796,8 @@ namespace AyaNova.Util throw new System.Exception(err); } //Known customer type users - await SeedUserAsync(log, 1, AuthorizationRoles.Customer, UserType.Customer, true, "Customer", "Customer", 0, KnownUserTags, null, NewObject.Id, null); - await SeedUserAsync(log, 1, AuthorizationRoles.Customer, UserType.Customer, true, "CustomerRestricted", "CustomerRestricted", 0, KnownUserTags, null, NewObject.Id, null); + KnownUserCustomerId = await SeedUserAsync(log, 1, AuthorizationRoles.Customer, UserType.Customer, true, "Customer", "Customer", 0, KnownUserTags, null, NewObject.Id, null); + KnownUserCustomerRestrictedId = await SeedUserAsync(log, 1, AuthorizationRoles.Customer, UserType.Customer, true, "CustomerRestricted", "CustomerRestricted", 0, KnownUserTags, null, NewObject.Id, null); } } @@ -845,8 +845,8 @@ namespace AyaNova.Util VendorIdForSubContractorUser = NewObject.Id; } - await SeedUserAsync(log, 1, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor, true, "SubContractorRestricted", "SubContractorRestricted", 0, KnownUserTags, VendorIdForSubContractorUser, null, null); - await SeedUserAsync(log, 1, AuthorizationRoles.SubContractor, UserType.ServiceContractor, true, "SubContractor", "SubContractor", 0, KnownUserTags, VendorIdForSubContractorUser, null, null); + KnownUserSubContractorRestrictedId = await SeedUserAsync(log, 1, AuthorizationRoles.SubContractorRestricted, UserType.ServiceContractor, true, "SubContractorRestricted", "SubContractorRestricted", 0, KnownUserTags, VendorIdForSubContractorUser, null, null); + KnownUserSubContractorId = await SeedUserAsync(log, 1, AuthorizationRoles.SubContractor, UserType.ServiceContractor, true, "SubContractor", "SubContractor", 0, KnownUserTags, VendorIdForSubContractorUser, null, null); } @@ -1458,11 +1458,11 @@ namespace AyaNova.Util /// Generate seed user with active=true /// (override to save typing) /// - public async Task SeedUserAsync(ILogger log, int count, AuthorizationRoles roles, UserType userType, string login, string password, List tags = null) + public async Task SeedUserAsync(ILogger log, int count, AuthorizationRoles roles, UserType userType, string login, string password, List tags = null) { try { - await SeedUserAsync(log, count, roles, userType, true, login, password, 0, tags); + return await SeedUserAsync(log, count, roles, userType, true, login, password, 0, tags); } catch { @@ -1475,6 +1475,13 @@ namespace AyaNova.Util public HashSet HashUserNames = new HashSet(); public List ServiceUserIds = new List(); private int TotalSeededUsers = 0; + public long KnownUserSubContractorId = 0; + public long KnownUserSubContractorRestrictedId = 0; + public long KnownUserTechId = 0; + public long KnownUserTechRestrictedId = 0; + public long KnownUserCustomerId = 0; + public long KnownUserCustomerRestrictedId = 0; + public async Task SeedUserAsync( ILogger log, int count, AuthorizationRoles roles, UserType userType, @@ -1545,10 +1552,9 @@ namespace AyaNova.Util { UserBiz biz = UserBiz.GetBiz(ct); var NewObject = await biz.CreateAsync(u); - if (u.UserType != UserType.NotService) - { + if (u.UserType == UserType.Service) ServiceUserIds.Add(u.Id); - } + TotalSeededUsers++; if (NewObject == null) { @@ -2141,17 +2147,17 @@ namespace AyaNova.Util o.Tags = RandomTags(); o.RateHour = Fake.Random.Decimal(1, 25); - o.RateHourCost=o.RateHour/2; + o.RateHourCost = o.RateHour / 2; o.RateHalfDay = o.RateHour * 4; - o.RateHalfDayCost=o.RateHalfDay/2; + o.RateHalfDayCost = o.RateHalfDay / 2; o.RateDay = o.RateHour * 8; - o.RateDayCost=o.RateDay/2; + o.RateDayCost = o.RateDay / 2; o.RateWeek = o.RateHour * 36.8m; - o.RateWeekCost=o.RateWeek/2; + o.RateWeekCost = o.RateWeek / 2; o.RateMonth = o.RateHour * 21 * 8; - o.RateMonthCost=o.RateMonth/2; + o.RateMonthCost = o.RateMonth / 2; o.RateYear = o.RateHour * 36.8m * 52; - o.RateYearCost=o.RateYear/2; + o.RateYearCost = o.RateYear / 2; o.DefaultRate = Fake.Random.Enum();