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_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\\"
|
||||
|
||||
@@ -190,17 +190,18 @@ namespace AyaNova.Api.Controllers
|
||||
PartBiz biz = PartBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var v = await ct.SaveChangesAsync();
|
||||
return Accepted();
|
||||
// var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
// if (o == null)
|
||||
// {
|
||||
// if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
// return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
// else
|
||||
// return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
// }
|
||||
// return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency })); ;
|
||||
|
||||
|
||||
var o = await biz.PutSerialsAsync(id, serials);
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
|
||||
//------------
|
||||
|
||||
@@ -181,6 +181,57 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//UPDATESERIALS
|
||||
//
|
||||
internal async Task<List<String>> PutSerialsAsync(long id, List<string> serials)
|
||||
{
|
||||
//Fixup serials
|
||||
|
||||
int nAdded = 0;
|
||||
int nRemoved = 0;
|
||||
var ExistingSerials = await ct.PartSerial.Where(z => z.PartId == id).OrderBy(z => z.Serial).ToListAsync();
|
||||
|
||||
//Remove any that should not be there anymore
|
||||
foreach (PartSerial ps in ExistingSerials)
|
||||
{
|
||||
if (!serials.Contains(ps.Serial))
|
||||
{
|
||||
ct.PartSerial.Remove(ps);
|
||||
nRemoved++;
|
||||
}
|
||||
}
|
||||
|
||||
//Add any new ones
|
||||
foreach (string s in serials)
|
||||
{
|
||||
if (!ExistingSerials.Any(z => z.Serial == s))
|
||||
{
|
||||
ct.PartSerial.Add(new PartSerial() { Serial = s, PartId = id });
|
||||
nAdded++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!await ExistsAsync(id))
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
else
|
||||
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||
return null;
|
||||
}
|
||||
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Modified, $"LT:PartSerialNumbersAvailable change (+{nAdded}, -{nRemoved})"), ct);
|
||||
|
||||
return await ct.PartSerial.Where(z => z.PartId == id).OrderBy(z => z.Serial).Select(z => z.Serial).ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//SEARCH
|
||||
//
|
||||
|
||||
@@ -651,6 +651,7 @@
|
||||
"PartSerialDateReceived": "Empfangen",
|
||||
"PartSerialSerialNumberNotUnique": "Für dieses Teil wurde bereits eine Seriennummer eingegeben",
|
||||
"PartSerialWarehouseID": "Teilelager",
|
||||
"PartSerialNumbersAvailable": "Verfügbare Seriennummern",
|
||||
"PartWarehouseDescription": "Beschreibung",
|
||||
"PartWarehouseList": "Teilelager",
|
||||
"PartWarehouseName": "Teilelager - Name",
|
||||
|
||||
@@ -651,6 +651,7 @@
|
||||
"PartSerialDateReceived": "Received",
|
||||
"PartSerialSerialNumberNotUnique": "Serial number already entered for this part",
|
||||
"PartSerialWarehouseID": "Part Warehouse",
|
||||
"PartSerialNumbersAvailable": "Available serial numbers",
|
||||
"PartWarehouseDescription": "Description",
|
||||
"PartWarehouseList": "Parts Warehouses",
|
||||
"PartWarehouseName": "Part Warehouse Name",
|
||||
|
||||
@@ -650,6 +650,7 @@
|
||||
"PartSerialDateReceived": "Recibido",
|
||||
"PartSerialSerialNumberNotUnique": "Número de serie ya introducido para esta pieza",
|
||||
"PartSerialWarehouseID": "Almacén de la pieza",
|
||||
"PartSerialNumbersAvailable": "Números de serie disponibles",
|
||||
"PartWarehouseDescription": "Descripción",
|
||||
"PartWarehouseList": "Almacenes de piezas",
|
||||
"PartWarehouseName": "Nombre de almacén de la pieza",
|
||||
|
||||
@@ -651,6 +651,7 @@
|
||||
"PartSerialDateReceived": "Réceptionné",
|
||||
"PartSerialSerialNumberNotUnique": "Numéro de série déjà saisi pour cette pièce",
|
||||
"PartSerialWarehouseID": "Magasin de pièces",
|
||||
"PartSerialNumbersAvailable": "Numéros de série disponibles",
|
||||
"PartWarehouseDescription": "Description",
|
||||
"PartWarehouseList": "Magasins de pièces",
|
||||
"PartWarehouseName": "Nom de magasin de pièces",
|
||||
|
||||
Reference in New Issue
Block a user