This commit is contained in:
2021-02-25 22:43:16 +00:00
parent e48b96f60a
commit 8c31bd19a0
2 changed files with 35 additions and 7 deletions

View File

@@ -348,6 +348,37 @@ namespace AyaNova.Biz
return ret;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//UPDATE PART COST
//
internal async Task<bool> PutPartCostAsync(long id, decimal newCost)
{
var dbObject = await ct.Part.FirstOrDefaultAsync(x => x.Id == id);
if (dbObject == null)
{
AddError(ApiErrorCode.NOT_FOUND, "id");
return false;
}
dbObject.Cost = newCost;
try
{
await ct.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!await ExistsAsync(id))
AddError(ApiErrorCode.NOT_FOUND);
else
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
return false;
}
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//SEARCH
//