This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage;
|
||||||
using AyaNova.Util;
|
using AyaNova.Util;
|
||||||
using AyaNova.Api.ControllerHelpers;
|
using AyaNova.Api.ControllerHelpers;
|
||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
@@ -688,79 +689,6 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// //UPDATE
|
|
||||||
// //
|
|
||||||
// internal async Task<WorkOrderState> StatePutAsync(WorkOrderState putObject)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// WorkOrderState dbObject = await StateGetAsync(putObject.Id, false);
|
|
||||||
// if (dbObject == null)
|
|
||||||
// {
|
|
||||||
// AddError(ApiErrorCode.NOT_FOUND, "id");
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// if (dbObject.Concurrency != putObject.Concurrency)
|
|
||||||
// {
|
|
||||||
// AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// await StateValidateAsync(putObject, dbObject);
|
|
||||||
// if (HasErrors) return null;
|
|
||||||
// ct.Replace(dbObject, putObject);
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// await ct.SaveChangesAsync();
|
|
||||||
// }
|
|
||||||
// catch (DbUpdateConcurrencyException)
|
|
||||||
// {
|
|
||||||
// if (!await ItemExistsAsync(putObject.Id))
|
|
||||||
// AddError(ApiErrorCode.NOT_FOUND);
|
|
||||||
// else
|
|
||||||
// AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, AyaType.WorkOrderStatus, AyaEvent.Modified), ct);
|
|
||||||
|
|
||||||
// await StateHandlePotentialNotificationEvent(AyaEvent.Modified, putObject, dbObject);
|
|
||||||
// return putObject;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// //DELETE
|
|
||||||
// //
|
|
||||||
// internal async Task<bool> StateDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
|
||||||
// {
|
|
||||||
// Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
|
||||||
// if (parentTransaction == null)
|
|
||||||
// transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// WorkOrderState dbObject = await StateGetAsync(id, false);
|
|
||||||
// StateValidateCanDelete(dbObject);
|
|
||||||
// if (HasErrors)
|
|
||||||
// return false;
|
|
||||||
|
|
||||||
// ct.WorkOrderState.Remove(dbObject);
|
|
||||||
// await ct.SaveChangesAsync();
|
|
||||||
|
|
||||||
// //Log event
|
|
||||||
// await EventLogProcessor.DeleteObjectLogAsync(UserId, AyaType.WorkOrderStatus, dbObject.Id, "wo:" + dbObject.WorkOrderId.ToString(), ct);
|
|
||||||
|
|
||||||
// //all good do the commit if it's ours
|
|
||||||
// if (parentTransaction == null)
|
|
||||||
// await transaction.CommitAsync();
|
|
||||||
// await StateHandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// //Just re-throw for now, let exception handler deal, but in future may want to deal with this more here
|
|
||||||
// throw;
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//VALIDATION
|
//VALIDATION
|
||||||
//
|
//
|
||||||
@@ -953,9 +881,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> ItemDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> ItemDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await ct.WorkOrderItem.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
var dbObject = await ct.WorkOrderItem.AsNoTracking().SingleOrDefaultAsync(z => z.Id == id);
|
||||||
@@ -1248,9 +1174,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> ExpenseDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> ExpenseDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await ExpenseGetAsync(id, false);
|
var dbObject = await ExpenseGetAsync(id, false);
|
||||||
@@ -1498,9 +1422,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> LaborDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> LaborDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await LaborGetAsync(id, false);
|
var dbObject = await LaborGetAsync(id, false);
|
||||||
@@ -1751,9 +1673,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> LoanDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> LoanDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await LoanGetAsync(id, false);
|
var dbObject = await LoanGetAsync(id, false);
|
||||||
@@ -2014,9 +1934,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> OutsideServiceDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> OutsideServiceDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await OutsideServiceGetAsync(id, false);
|
var dbObject = await OutsideServiceGetAsync(id, false);
|
||||||
@@ -2268,9 +2186,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> PartDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> PartDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await PartGetAsync(id, false);
|
var dbObject = await PartGetAsync(id, false);
|
||||||
@@ -2521,9 +2437,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> PartRequestDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> PartRequestDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await PartRequestGetAsync(id, false);
|
var dbObject = await PartRequestGetAsync(id, false);
|
||||||
@@ -2750,9 +2664,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> ScheduledUserDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> ScheduledUserDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await ScheduledUserGetAsync(id, false);
|
var dbObject = await ScheduledUserGetAsync(id, false);
|
||||||
@@ -2979,9 +2891,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> TaskDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> TaskDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await TaskGetAsync(id, false);
|
var dbObject = await TaskGetAsync(id, false);
|
||||||
@@ -3231,9 +3141,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> TravelDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> TravelDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await TravelGetAsync(id, false);
|
var dbObject = await TravelGetAsync(id, false);
|
||||||
@@ -3485,9 +3393,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
internal async Task<bool> UnitDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
internal async Task<bool> UnitDeleteAsync(long id, Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction parentTransaction = null)
|
||||||
{
|
{
|
||||||
Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction transaction = null;
|
var transaction = parentTransaction ?? await ct.Database.BeginTransactionAsync();
|
||||||
if (parentTransaction == null)
|
|
||||||
transaction = await ct.Database.BeginTransactionAsync();
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dbObject = await UnitGetAsync(id, false);
|
var dbObject = await UnitGetAsync(id, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user