This commit is contained in:
@@ -111,35 +111,67 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//UPDATE
|
||||
//
|
||||
|
||||
//put
|
||||
internal async Task<bool> PutAsync(FormCustom dbObject, FormCustom inObj)
|
||||
internal async Task<FormCustom> PutAsync(FormCustom putObject)
|
||||
{
|
||||
|
||||
//todo: replace with new put methodology
|
||||
|
||||
//Replace the db object with the PUT object
|
||||
CopyObject.Copy(inObj, dbObject, "Id");
|
||||
//Set "original" value of concurrency token to input token
|
||||
//this will allow EF to check it out
|
||||
ct.Entry(dbObject).OriginalValues["Concurrency"] = inObj.Concurrency;
|
||||
|
||||
await ValidateAsync(dbObject, false);
|
||||
var dbObject = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(z => z.FormKey == putObject.FormKey);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "formKey");
|
||||
return null;
|
||||
}
|
||||
if (dbObject.Concurrency != putObject.Concurrency)
|
||||
{
|
||||
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||
return null;
|
||||
}
|
||||
dbObject.Template = JsonUtil.CompactJson(putObject.Template);
|
||||
putObject.Id=dbObject.Id;//weird workaround needed because ID is not sent with the putobject for...reasons 🤷?
|
||||
await ValidateAsync(putObject, false);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
|
||||
dbObject.Template = JsonUtil.CompactJson(dbObject.Template);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
return null;
|
||||
ct.Replace(dbObject, putObject);
|
||||
try
|
||||
{
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!await ExistsAsync(putObject.FormKey))
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
else
|
||||
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||
return null;
|
||||
}
|
||||
//Log modification and save context
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||
return putObject;
|
||||
// //todo: replace with new put methodology
|
||||
|
||||
// //Replace the db object with the PUT object
|
||||
// CopyObject.Copy(putObject, dbObject, "Id");
|
||||
// //Set "original" value of concurrency token to input token
|
||||
// //this will allow EF to check it out
|
||||
// ct.Entry(dbObject).OriginalValues["Concurrency"] = putObject.Concurrency;
|
||||
|
||||
// await ValidateAsync(dbObject, false);
|
||||
// if (HasErrors)
|
||||
// return false;
|
||||
|
||||
// dbObject.Template = JsonUtil.CompactJson(dbObject.Template);
|
||||
// await ct.SaveChangesAsync();
|
||||
|
||||
// //Log modification and save context
|
||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||
|
||||
|
||||
return true;
|
||||
// return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1013,7 +1013,8 @@ namespace AyaNova.Biz
|
||||
l.Add(new FormField { TKey = "TaxBAmt", FieldKey = "ExpenseTaxBViz", TKeySection = "WorkOrderItemExpense", Requireable = false });
|
||||
l.Add(new FormField { TKey = "LineTotal", FieldKey = "ExpenseLineTotalViz", TKeySection = "WorkOrderItemExpense", Requireable = false });
|
||||
|
||||
//WORKORDER ITEM LOAN
|
||||
//WORKORDER ITEM LOAN WorkOrderItemLoanRate ?
|
||||
l.Add(new FormField { TKey = "WorkOrderItemLoanRate", TKeySection = "WorkOrderItemLoan", ModelProperty = "Rate", Requireable = false });
|
||||
l.Add(new FormField { TKey = "WorkOrderItemLoanNotes", TKeySection = "WorkOrderItemLoan", ModelProperty = "Notes" });
|
||||
l.Add(new FormField { TKey = "WorkOrderItemLoanOutDate", TKeySection = "WorkOrderItemLoan", ModelProperty = "OutDate" });
|
||||
l.Add(new FormField { TKey = "WorkOrderItemLoanDueDate", TKeySection = "WorkOrderItemLoan", ModelProperty = "DueDate" });
|
||||
@@ -1023,7 +1024,7 @@ namespace AyaNova.Biz
|
||||
l.Add(new FormField { TKey = "ListPrice", FieldKey = "LoanListPrice", TKeySection = "WorkOrderItemLoan", Requireable = false });
|
||||
l.Add(new FormField { TKey = "Price", FieldKey = "LoanPriceViz", TKeySection = "WorkOrderItemLoan", Requireable = false });
|
||||
l.Add(new FormField { TKey = "PriceOverride", FieldKey = "LoanPriceOverride", TKeySection = "WorkOrderItemLoan", ModelProperty = "PriceOverride" });
|
||||
l.Add(new FormField { TKey = "UnitOfMeasure", FieldKey = "LoanUnitOfMeasureViz", TKeySection = "WorkOrderItemLoan", Requireable = false });
|
||||
//l.Add(new FormField { TKey = "UnitOfMeasure", FieldKey = "LoanUnitOfMeasureViz", TKeySection = "WorkOrderItemLoan", Requireable = false });
|
||||
l.Add(new FormField { TKey = "NetPrice", FieldKey = "LoanNetViz", TKeySection = "WorkOrderItemLoan", Requireable = false });
|
||||
l.Add(new FormField { TKey = "TaxAAmt", FieldKey = "LoanTaxAViz", TKeySection = "WorkOrderItemLoan", Requireable = false });
|
||||
l.Add(new FormField { TKey = "TaxBAmt", FieldKey = "LoanTaxBViz", TKeySection = "WorkOrderItemLoan", Requireable = false });
|
||||
|
||||
Reference in New Issue
Block a user