This commit is contained in:
@@ -2,7 +2,8 @@ PRIORITY - ALWAYS Lowest level stuff first
|
||||
=-=-=-=-
|
||||
|
||||
todo: switch to Identity column from serial column as it's the proper way to do autoid in postgres now
|
||||
|
||||
todo: uint isn't very big, maybe I should use long in it's place everywhere (concurrency token??)
|
||||
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types
|
||||
todo: AUTO ID GENERATOR
|
||||
change to a dedicated spot in global rather than inferring as it is not right practically for reasons
|
||||
Get the auto-id most recent values at boot time
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace AyaNova.Api.Controllers
|
||||
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
return Ok(ApiOkResponse.Response(o, !Authorized.HasModifyRole(HttpContext.Items, biz.BizType)));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Put (update) Widget
|
||||
/// </summary>
|
||||
@@ -156,7 +156,31 @@ namespace AyaNova.Api.Controllers
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reset serial number
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="newSerial">Next starting value for auto generated serial numbers</param>
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns>Widget</returns>
|
||||
[HttpPost("reset-serial/{newSerial}")]
|
||||
public async Task<IActionResult> ResetSerial([FromRoute] long newSerial, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
bool result=await biz.ResetSerial(newSerial);
|
||||
if (!result)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
//TEST ROUTES
|
||||
//
|
||||
|
||||
@@ -170,6 +170,22 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//RESET SERIAL
|
||||
//
|
||||
internal async Task<bool> ResetSerial(long newSerial)
|
||||
{
|
||||
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.ResetSerial,newSerial.ToString()), ct);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//SEARCH
|
||||
//
|
||||
|
||||
@@ -229,8 +229,8 @@ namespace AyaNova.Util
|
||||
//query for most recently used serial number
|
||||
//(note, can't query for highest serial as it can and likely will reset or be changed manually from time to time
|
||||
// so the algorithm is to keep the most recent sequence going on startup of the server)
|
||||
var serializedObject = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
|
||||
WIDGET_SERIAL = new AutoId(serializedObject == null ? 0 : serializedObject.Serial);
|
||||
// var serializedObject = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
|
||||
// WIDGET_SERIAL = new AutoId(serializedObject == null ? 0 : serializedObject.Serial);
|
||||
|
||||
// var MostRecentWidget = ct.Widget.AsNoTracking().OrderByDescending(x => x.Id).FirstOrDefault();
|
||||
// uint MaxWidgetId = 0;
|
||||
|
||||
Reference in New Issue
Block a user