This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -53,7 +53,7 @@
|
|||||||
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
"AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles",
|
||||||
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
"AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles",
|
||||||
"AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles",
|
"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_SEEDLEVEL": "small",
|
||||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
|
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7",
|
||||||
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"
|
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\"
|
||||||
|
|||||||
@@ -92,6 +92,41 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Creating a user creates a user options so no need for create ever
|
||||||
|
// /// <summary>
|
||||||
|
// /// Create UserOptions
|
||||||
|
// /// </summary>
|
||||||
|
// /// <param name="newObject"></param>
|
||||||
|
// /// <param name="apiVersion">From route path</param>
|
||||||
|
// /// <returns></returns>
|
||||||
|
// [HttpPost]
|
||||||
|
// public async Task<IActionResult> PostUserOptions([FromBody] UserOptions newObject, ApiVersion apiVersion)
|
||||||
|
// {
|
||||||
|
// if (!serverState.IsOpen)
|
||||||
|
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
// // var UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||||
|
|
||||||
|
// // //preclearance
|
||||||
|
// // //the biz object will further check
|
||||||
|
// // if (newObject.Id != UserId)
|
||||||
|
// // {
|
||||||
|
// // //Also used for Contacts (customer type user or ho type user)
|
||||||
|
// // //by users with no User right so further biz rule required depending on usertype
|
||||||
|
// // //this is just phase 1
|
||||||
|
// // if (!Authorized.HasCreateRole(HttpContext.Items, AyaType.User) && !Authorized.HasCreateRole(HttpContext.Items, AyaType.Customer))
|
||||||
|
// // return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
// // }
|
||||||
|
// UserOptionsBiz biz = new UserOptionsBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
|
||||||
|
// if (!ModelState.IsValid)
|
||||||
|
// return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
// UserOptions o = await biz.CreateAsync(newObject);
|
||||||
|
// if (o == null)
|
||||||
|
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
|
// else
|
||||||
|
// return CreatedAtAction(nameof(UserOptionsController.GetUserOptions), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update UserOptions
|
/// Update UserOptions
|
||||||
@@ -106,9 +141,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
{
|
|
||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
}
|
|
||||||
var UserId = UserIdFromContext.Id(HttpContext.Items);
|
var UserId = UserIdFromContext.Id(HttpContext.Items);
|
||||||
|
|
||||||
var o = await ct.UserOptions.SingleOrDefaultAsync(z => z.UserId == id);
|
var o = await ct.UserOptions.SingleOrDefaultAsync(z => z.UserId == id);
|
||||||
@@ -118,6 +152,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//preclearance
|
||||||
|
//the biz object will further check
|
||||||
if (id != UserId)
|
if (id != UserId)
|
||||||
{
|
{
|
||||||
//Also used for Contacts (customer type user or ho type user)
|
//Also used for Contacts (customer type user or ho type user)
|
||||||
|
|||||||
@@ -37,10 +37,50 @@ namespace AyaNova.Biz
|
|||||||
//UPDATE
|
//UPDATE
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//Creating a user creates a user options so no need for create ever
|
||||||
|
|
||||||
|
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// //CREATE
|
||||||
|
// //
|
||||||
|
// internal async Task<UserOptions> CreateAsync(UserOptions newObject)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// User u = await ct.User.AsNoTracking().SingleOrDefaultAsync(z => z.Id == newObject.UserId);
|
||||||
|
// if (u == null)
|
||||||
|
// {
|
||||||
|
// AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
// //Also used for Contacts (customer type user or ho type user)
|
||||||
|
// //by users with no User right but with Customer rights so need to double check here
|
||||||
|
// if (
|
||||||
|
// (u.IsOutsideUser && !Authorized.HasModifyRole(CurrentUserRoles, AyaType.Customer)) ||
|
||||||
|
// (!u.IsOutsideUser && !Authorized.HasModifyRole(CurrentUserRoles, AyaType.User))
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// AddError(ApiErrorCode.NOT_AUTHORIZED);
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Validate(newObject);
|
||||||
|
// if (HasErrors)
|
||||||
|
// return null;
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
|
||||||
|
// await ct.UserOptions.AddAsync(newObject);
|
||||||
|
// await ct.SaveChangesAsync();
|
||||||
|
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||||
|
|
||||||
|
// return newObject;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
//put
|
//put
|
||||||
internal async Task<bool> PutAsync(UserOptions dbObject, UserOptions inObj)
|
internal async Task<bool> PutAsync(UserOptions dbObject, UserOptions inObj)
|
||||||
{
|
{
|
||||||
//todo: update to use the new PUT methodology?
|
|
||||||
//if it's not the user's own options then we need to check it just as for User / Contact objects
|
//if it's not the user's own options then we need to check it just as for User / Contact objects
|
||||||
if (dbObject.Id != UserId)
|
if (dbObject.Id != UserId)
|
||||||
{
|
{
|
||||||
@@ -66,7 +106,9 @@ namespace AyaNova.Biz
|
|||||||
CopyObject.Copy(inObj, dbObject, "Id, UserId");
|
CopyObject.Copy(inObj, dbObject, "Id, UserId");
|
||||||
//Set "original" value of concurrency token to input token
|
//Set "original" value of concurrency token to input token
|
||||||
//this will allow EF to check it out
|
//this will allow EF to check it out
|
||||||
ct.Entry(dbObject).OriginalValues["Concurrency"] = inObj.Concurrency;
|
//BUT NOT IF IT"S FROM A DUPLICATION OP (CONCURRENCY=0)
|
||||||
|
if (inObj.Concurrency != 0)
|
||||||
|
ct.Entry(dbObject).OriginalValues["Concurrency"] = inObj.Concurrency;
|
||||||
|
|
||||||
Validate(dbObject);
|
Validate(dbObject);
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace AyaNova.Util
|
|||||||
private const int DESIRED_SCHEMA_LEVEL = 1;
|
private const int DESIRED_SCHEMA_LEVEL = 1;
|
||||||
|
|
||||||
internal const long EXPECTED_COLUMN_COUNT = 962;
|
internal const long EXPECTED_COLUMN_COUNT = 962;
|
||||||
internal const long EXPECTED_INDEX_COUNT = 137;
|
internal const long EXPECTED_INDEX_COUNT = 138;
|
||||||
internal const long EXPECTED_CHECK_CONSTRAINTS = 415;
|
internal const long EXPECTED_CHECK_CONSTRAINTS = 415;
|
||||||
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 118;
|
internal const long EXPECTED_FOREIGN_KEY_CONSTRAINTS = 118;
|
||||||
internal const long EXPECTED_VIEWS = 6;
|
internal const long EXPECTED_VIEWS = 6;
|
||||||
@@ -464,7 +464,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
|||||||
|
|
||||||
//Add user options table
|
//Add user options table
|
||||||
await ExecQueryAsync("CREATE TABLE auseroptions (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, "
|
await ExecQueryAsync("CREATE TABLE auseroptions (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, "
|
||||||
+ "userid BIGINT NOT NULL REFERENCES auser (id), translationid BIGINT NOT NULL REFERENCES atranslation (id), languageoverride TEXT, timezoneoverride TEXT, "
|
+ "userid BIGINT NOT NULL UNIQUE REFERENCES auser (id), translationid BIGINT NOT NULL REFERENCES atranslation (id), languageoverride TEXT, timezoneoverride TEXT, "
|
||||||
+ "currencyname TEXT, hour12 BOOL NOT NULL, emailaddress TEXT, phone1 TEXT, phone2 TEXT, phone3 TEXT, uicolor VARCHAR(12) NOT NULL default '#000000', mapurltemplate TEXT)");
|
+ "currencyname TEXT, hour12 BOOL NOT NULL, emailaddress TEXT, phone1 TEXT, phone2 TEXT, phone3 TEXT, uicolor VARCHAR(12) NOT NULL default '#000000', mapurltemplate TEXT)");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user