diff --git a/.vscode/launch.json b/.vscode/launch.json index 0e2049e9..8fd97968 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -53,7 +53,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "false", + "AYANOVA_SERVER_TEST_MODE": "true", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index 4d033a4e..2f45e120 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -506,15 +506,15 @@ namespace AyaNova.Biz //Validate subcontractor type user if (!SeedOrImportRelaxedRulesMode && proposedObj.UserType == UserType.ServiceContractor) { - if (proposedObj.SubVendorId == null || proposedObj.SubVendorId == 0) + if (proposedObj.VendorId == null || proposedObj.VendorId == 0) { - AddError(ApiErrorCode.VALIDATION_REQUIRED, "SubVendorId"); + AddError(ApiErrorCode.VALIDATION_REQUIRED, "VendorId"); } else { - //verify that VENDOR SubVendorId exists - if (!await ct.Vendor.AnyAsync(z => z.Id == proposedObj.SubVendorId)) - AddError(ApiErrorCode.NOT_FOUND, "SubVendorId"); + //verify that VENDOR VendorId exists + if (!await ct.Vendor.AnyAsync(z => z.Id == proposedObj.VendorId)) + AddError(ApiErrorCode.NOT_FOUND, "VendorId"); } } @@ -592,26 +592,7 @@ namespace AyaNova.Biz return DownloadUser; } - //replaced by dtUser object instead - // internal static object CleanUserForReturn(User o) - // { - // return new - // { - // Id = o.Id, - // Concurrency = o.Concurrency, - // Active = o.Active, - // Name = o.Name, - // Roles = o.Roles, - // TranslationId = o.UserOptions.TranslationId, - // UserType = o.UserType, - // EmployeeNumber = o.EmployeeNumber, - // Notes = o.Notes, - // CustomerId = o.CustomerId, - // HeadOfficeId = o.HeadOfficeId, - // SubVendorId = o.SubVendorId - // }; - // } - + //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/server/AyaNova/models/User.cs b/server/AyaNova/models/User.cs index db44d5e2..e3cf44d9 100644 --- a/server/AyaNova/models/User.cs +++ b/server/AyaNova/models/User.cs @@ -25,7 +25,7 @@ namespace AyaNova.Models public string Notes { get; set; } public long? CustomerId { get; set; } public long? HeadOfficeId { get; set; } - public long? SubVendorId { get; set; } + public long? VendorId { get; set; } public string Wiki { get; set; } public string CustomFields { get; set; } public List Tags { get; set; } @@ -69,7 +69,7 @@ namespace AyaNova.Models public string Notes { get; set; } public long? CustomerId { get; set; } public long? HeadOfficeId { get; set; } - public long? SubVendorId { get; set; } + public long? VendorId { get; set; } public string Wiki { get; set; } public string CustomFields { get; set; } @@ -80,6 +80,15 @@ namespace AyaNova.Models [JsonIgnore]//hide from being returned (as null anyway) with User object in routes public UserOptions UserOptions { get; set; } + [JsonIgnore] + public Customer Customer { get; set; } + + [JsonIgnore] + public HeadOffice HeadOffice { get; set; } + + [JsonIgnore] + public Vendor Vendor { get; set; } + [JsonIgnore]//hide from being returned (as null anyway) with User object in routes public Widget Widget { get; set; } diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index c9f20f41..7089484e 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -330,7 +330,7 @@ $BODY$; await ExecQueryAsync("CREATE TABLE auser (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, active bool not null, name text not null unique, " + "lastlogin timestamp, login text not null unique, password text not null, salt text not null, roles integer not null, currentauthtoken text, " + "dlkey text, dlkeyexpire timestamp, usertype integer not null, employeenumber text, notes text, customerid bigint, " + - "headofficeid bigint, subvendorid bigint, wiki text, customfields text, tags varchar(255) ARRAY)"); + "headofficeid bigint, vendorid bigint, wiki text, customfields text, tags varchar(255) ARRAY)"); //Index for name fetching await ExecQueryAsync("CREATE UNIQUE INDEX auser_name_id_idx ON auser (id, name);"); @@ -489,6 +489,7 @@ $BODY$; "postaddress text, postcity text, postregion text, postcountry text, postcode text, address text, city text, region text, country text, latitude decimal(8,6), longitude decimal(9,6))"); await ExecQueryAsync("CREATE UNIQUE INDEX acustomer_name_id_idx ON acustomer (id, name);"); await ExecQueryAsync("CREATE INDEX acustomer_tags ON acustomer using GIN(tags)"); + await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (customerid) REFERENCES acustomer(id)"); //CONTRACT @@ -506,6 +507,7 @@ $BODY$; await ExecQueryAsync("CREATE UNIQUE INDEX aheadoffice_name_id_idx ON aheadoffice (id, name);"); await ExecQueryAsync("CREATE INDEX aheadoffice_tags ON aheadoffice using GIN(tags)"); await ExecQueryAsync("ALTER TABLE acustomer add column headofficeid bigint null references aheadoffice"); + await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (headofficeid) REFERENCES aheadoffice(id)"); //LOANUNIT @@ -549,6 +551,7 @@ $BODY$; "notes text, wiki text, customfields text, tags varchar(255) ARRAY )"); await ExecQueryAsync("CREATE UNIQUE INDEX avendor_name_id_idx ON avendor (id, name);"); await ExecQueryAsync("CREATE INDEX avendor_tags ON avendor using GIN(tags)"); + await ExecQueryAsync("ALTER TABLE auser add FOREIGN KEY (vendorid) REFERENCES avendor(id)"); //---------- //WORKORDER