This commit is contained in:
@@ -307,7 +307,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Customer))
|
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.Customer))
|
||||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
|
||||||
var ret = await ct.User.Include(o => o.UserOptions).Where(z => z.UserType == UserType.Customer || z.UserType == UserType.HeadOffice).Select(z => new
|
var ret = await ct.User.Include(c => c.Customer).Include(h => h.HeadOffice).Include(o => o.UserOptions).Where(z => z.UserType == UserType.Customer || z.UserType == UserType.HeadOffice).Select(z => new
|
||||||
{
|
{
|
||||||
Id = z.Id,
|
Id = z.Id,
|
||||||
Active = z.Active,
|
Active = z.Active,
|
||||||
@@ -317,7 +317,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
EmailAddress = z.UserOptions.EmailAddress,
|
EmailAddress = z.UserOptions.EmailAddress,
|
||||||
Phone1 = z.UserOptions.Phone1,
|
Phone1 = z.UserOptions.Phone1,
|
||||||
Phone2 = z.UserOptions.Phone2,
|
Phone2 = z.UserOptions.Phone2,
|
||||||
Phone3 = z.UserOptions.Phone3
|
Phone3 = z.UserOptions.Phone3,
|
||||||
|
Organization = z.HeadOffice.Name ?? z.Customer.Name
|
||||||
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
return Ok(ApiOkResponse.Response(ret));
|
return Ok(ApiOkResponse.Response(ret));
|
||||||
|
|||||||
@@ -273,11 +273,6 @@ namespace AyaNova.Util
|
|||||||
//1 accountant / bookkeeper
|
//1 accountant / bookkeeper
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NotService);
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NotService);
|
||||||
|
|
||||||
//10 full on customer users
|
|
||||||
await GenSeedUserAsync(log, 10, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
|
||||||
|
|
||||||
//10 limited customer users
|
|
||||||
await GenSeedUserAsync(log, 10, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
|
||||||
|
|
||||||
//WIDGETS
|
//WIDGETS
|
||||||
await GenSeedWidgetAsync(log, 500);
|
await GenSeedWidgetAsync(log, 500);
|
||||||
@@ -347,11 +342,7 @@ namespace AyaNova.Util
|
|||||||
//5 accountant / bookkeeper
|
//5 accountant / bookkeeper
|
||||||
await GenSeedUserAsync(log, 5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NotService);
|
await GenSeedUserAsync(log, 5, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NotService);
|
||||||
|
|
||||||
//100 full on customer users
|
|
||||||
await GenSeedUserAsync(log, 20, AuthorizationRoles.CustomerFull, UserType.Customer);
|
|
||||||
|
|
||||||
//100 limited customer users
|
|
||||||
await GenSeedUserAsync(log, 20, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
|
||||||
|
|
||||||
|
|
||||||
//WIDGETS
|
//WIDGETS
|
||||||
@@ -422,11 +413,7 @@ namespace AyaNova.Util
|
|||||||
//accountant / bookkeeper
|
//accountant / bookkeeper
|
||||||
await GenSeedUserAsync(log, 20, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NotService);
|
await GenSeedUserAsync(log, 20, AuthorizationRoles.AccountingFull | AuthorizationRoles.BizAdminLimited, UserType.NotService);
|
||||||
|
|
||||||
//full on customer users
|
|
||||||
await GenSeedUserAsync(log, 200, AuthorizationRoles.CustomerFull, UserType.Customer);
|
|
||||||
|
|
||||||
//limited customer users
|
|
||||||
await GenSeedUserAsync(log, 50, AuthorizationRoles.CustomerLimited, UserType.Customer);
|
|
||||||
|
|
||||||
|
|
||||||
//WIDGETS
|
//WIDGETS
|
||||||
@@ -541,9 +528,7 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.SubContractorLimited, UserType.ServiceContractor, "SubContractorLimited", "SubContractorLimited", KnownUserTags);
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.SubContractorLimited, UserType.ServiceContractor, "SubContractorLimited", "SubContractorLimited", KnownUserTags);
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.SubContractorFull, UserType.ServiceContractor, "SubContractorFull", "SubContractorFull", KnownUserTags);
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.SubContractorFull, UserType.ServiceContractor, "SubContractorFull", "SubContractorFull", KnownUserTags);
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.CustomerLimited, UserType.Customer, "CustomerLimited", "CustomerLimited", KnownUserTags);
|
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.Customer, "CustomerFull", "CustomerFull", KnownUserTags);
|
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.CustomerFull, UserType.HeadOffice, "HeadOffice", "HeadOffice", KnownUserTags);
|
|
||||||
|
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminLimited, UserType.NotService, "OpsAdminLimited", "OpsAdminLimited", KnownUserTags);
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminLimited, UserType.NotService, "OpsAdminLimited", "OpsAdminLimited", KnownUserTags);
|
||||||
await GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NotService, "OpsAdminFull", "OpsAdminFull", KnownUserTags);
|
await GenSeedUserAsync(log, 1, AuthorizationRoles.OpsAdminFull, UserType.NotService, "OpsAdminFull", "OpsAdminFull", KnownUserTags);
|
||||||
@@ -588,7 +573,7 @@ namespace AyaNova.Util
|
|||||||
|
|
||||||
|
|
||||||
public async Task GenSeedUserAsync(ILogger log, int count, AuthorizationRoles roles, UserType userType,
|
public async Task GenSeedUserAsync(ILogger log, int count, AuthorizationRoles roles, UserType userType,
|
||||||
bool active = true, string login = null, string password = null, long translationId = 0, List<string> tags = null)
|
bool active = true, string login = null, string password = null, long translationId = 0, List<string> tags = null, long? vendorId = null, long? customerId = null, long? headofficeId = null)
|
||||||
{
|
{
|
||||||
if (translationId == 0)
|
if (translationId == 0)
|
||||||
translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
|
translationId = ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID;
|
||||||
@@ -615,7 +600,6 @@ namespace AyaNova.Util
|
|||||||
else
|
else
|
||||||
u.Password = u.Login;
|
u.Password = u.Login;
|
||||||
u.Roles = roles;
|
u.Roles = roles;
|
||||||
|
|
||||||
u.UserType = userType;
|
u.UserType = userType;
|
||||||
u.EmployeeNumber = "A-" + (454 + SeededUserCount + x).ToString() + "-Y";
|
u.EmployeeNumber = "A-" + (454 + SeededUserCount + x).ToString() + "-Y";
|
||||||
u.Notes = Fake.Lorem.Sentence(null, 5);//Fake.Lorem.Paragraph(2);
|
u.Notes = Fake.Lorem.Sentence(null, 5);//Fake.Lorem.Paragraph(2);
|
||||||
@@ -625,6 +609,14 @@ namespace AyaNova.Util
|
|||||||
u.Tags = RandomTags();
|
u.Tags = RandomTags();
|
||||||
else
|
else
|
||||||
u.Tags = tags;
|
u.Tags = tags;
|
||||||
|
|
||||||
|
//relations
|
||||||
|
u.VendorId = vendorId;
|
||||||
|
u.CustomerId = customerId;
|
||||||
|
u.HeadOfficeId = headofficeId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Children and relations
|
//Children and relations
|
||||||
u.UserOptions = new UserOptions();
|
u.UserOptions = new UserOptions();
|
||||||
u.UserOptions.TranslationId = translationId;
|
u.UserOptions.TranslationId = translationId;
|
||||||
@@ -746,12 +738,17 @@ namespace AyaNova.Util
|
|||||||
{
|
{
|
||||||
CustomerBiz biz = CustomerBiz.GetBiz(ct);
|
CustomerBiz biz = CustomerBiz.GetBiz(ct);
|
||||||
var NewObject = await biz.CreateAsync(o);
|
var NewObject = await biz.CreateAsync(o);
|
||||||
|
|
||||||
if (NewObject == null)
|
if (NewObject == null)
|
||||||
{
|
{
|
||||||
var err = $"Seeder::GenSeedCustomer error creating customer {o.Name}\r\n{biz.GetErrorsAsString()}";
|
var err = $"Seeder::GenSeedCustomer error creating customer {o.Name}\r\n{biz.GetErrorsAsString()}";
|
||||||
log.LogError(err);
|
log.LogError(err);
|
||||||
throw new System.Exception(err);
|
throw new System.Exception(err);
|
||||||
}
|
}
|
||||||
|
//Customer contacts
|
||||||
|
await GenSeedUserAsync(log, 2, AuthorizationRoles.CustomerFull, UserType.Customer, true, null, null, 0, null, null, NewObject.Id, null);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user