This commit is contained in:
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -55,7 +55,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": "true",
|
||||
"AYANOVA_SERVER_TEST_MODE": "false",
|
||||
"AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small",
|
||||
"AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-8",
|
||||
"AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_14\\bin\\"
|
||||
|
||||
@@ -98,6 +98,31 @@ namespace AyaNova.Api.Controllers
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get WorkOrder for customer
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Customer WorkOrder</returns>
|
||||
[HttpGet("customer/{id}")]
|
||||
public async Task<IActionResult> GetCustomerWorkOrder([FromRoute] long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
WorkOrderBiz biz = WorkOrderBiz.GetBiz(ct, HttpContext);
|
||||
// if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||
// return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
|
||||
//does this user have the right to even fetch a customer view workorder??
|
||||
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
var o = await biz.WorkOrderGetForCustomerAsync(id, true);
|
||||
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update WorkOrder
|
||||
|
||||
@@ -430,7 +430,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Tech | AuthorizationRoles.SubContractor | AuthorizationRoles.Accounting,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.Sales |
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted | AuthorizationRoles.CustomerRestricted | AuthorizationRoles.Customer,
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted,
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
@@ -441,7 +441,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Tech | AuthorizationRoles.SubContractor | AuthorizationRoles.Accounting,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.Sales |
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted | AuthorizationRoles.CustomerRestricted | AuthorizationRoles.Customer,
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted,
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
@@ -452,7 +452,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Tech | AuthorizationRoles.SubContractor | AuthorizationRoles.Accounting,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.Sales |
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted | AuthorizationRoles.CustomerRestricted | AuthorizationRoles.Customer,
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted ,
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
@@ -463,7 +463,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Tech | AuthorizationRoles.TechRestricted | AuthorizationRoles.SubContractor | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.Accounting,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.Sales |
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted | AuthorizationRoles.CustomerRestricted | AuthorizationRoles.Customer,
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted ,
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
@@ -471,7 +471,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdmin | AuthorizationRoles.Service | AuthorizationRoles.Tech | AuthorizationRoles.Accounting,
|
||||
ReadFullRecord = AuthorizationRoles.BizAdminRestricted | AuthorizationRoles.ServiceRestricted | AuthorizationRoles.Sales |
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted | AuthorizationRoles.CustomerRestricted | AuthorizationRoles.Customer,
|
||||
AuthorizationRoles.SalesRestricted | AuthorizationRoles.SubContractorRestricted | AuthorizationRoles.TechRestricted,
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
}
|
||||
|
||||
internal static async Task<CustomerRightsRecord> CustomerUserEffectiveRightsAsync(long userId)
|
||||
internal static async Task<CustomerRightsRecord> CustomerUserEffectiveRightsAsync(long userId, long? workorderId=null)
|
||||
{
|
||||
using (AyContext ct = ServiceProviderProvider.DBContext)
|
||||
{
|
||||
|
||||
@@ -302,6 +302,94 @@ namespace AyaNova.Biz
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// GET
|
||||
//
|
||||
internal async Task<WorkOrder> WorkOrderGetForCustomerAsync(long id, bool populateDisplayFields, bool logTheGetEvent = true, bool populateForReporting = false)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
|
||||
// var ret = await WorkOrderGetFullAsync(id);
|
||||
|
||||
// if (ret != null)
|
||||
// {
|
||||
// var stat = await GetCurrentWorkOrderStatusFromRelatedAsync(BizType, ret.Id);
|
||||
// ret.IsLockedAtServer = stat.Locked;
|
||||
|
||||
// var userIsTechRestricted = UserIsTechRestricted;
|
||||
// var userIsSubContractorFull = UserIsSubContractorFull;
|
||||
// var userIsSubContractorRestricted = UserIsSubContractorRestricted;
|
||||
// var userIsRestricted = (userIsTechRestricted || userIsSubContractorFull || userIsSubContractorRestricted);
|
||||
|
||||
|
||||
// if (userIsRestricted)
|
||||
// {
|
||||
// //Restricted users can only work with workorder items they are scheduled on
|
||||
|
||||
// List<WorkOrderItem> removeItems = new List<WorkOrderItem>();
|
||||
// //gather list of items to remove by checking if they are scheduled on them or not
|
||||
// foreach (WorkOrderItem wi in ret.Items)
|
||||
// {
|
||||
// var userIsSelfScheduledOnThisItem = false;
|
||||
// foreach (WorkOrderItemScheduledUser su in wi.ScheduledUsers)
|
||||
// {
|
||||
// if (su.UserId == UserId)
|
||||
// {
|
||||
// userIsSelfScheduledOnThisItem = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!userIsSelfScheduledOnThisItem) removeItems.Add(wi);
|
||||
// }
|
||||
// foreach (var removeitem in removeItems)
|
||||
// {
|
||||
// ret.Items.Remove(removeitem);
|
||||
// ret.IsCompleteRecord = false;
|
||||
// }
|
||||
|
||||
// //Restricted users may have further restrictions
|
||||
// foreach (WorkOrderItem wi in ret.Items)
|
||||
// {
|
||||
// //all restricted types
|
||||
// wi.ScheduledUsers.RemoveAll(x => x.UserId != UserId);
|
||||
// wi.Labors.RemoveAll(x => x.UserId != UserId);
|
||||
// wi.Travels.RemoveAll(x => x.UserId != UserId);
|
||||
|
||||
// if (userIsTechRestricted)
|
||||
// {
|
||||
// wi.Expenses.RemoveAll(x => x.UserId != UserId);
|
||||
// }
|
||||
|
||||
// if (userIsSubContractorFull)
|
||||
// {
|
||||
// wi.Expenses.RemoveAll(x => true);
|
||||
// wi.OutsideServices.RemoveAll(x => true);
|
||||
// }
|
||||
|
||||
// if (userIsSubContractorRestricted)
|
||||
// {
|
||||
// wi.Units.RemoveAll(x => true);
|
||||
// wi.Parts.RemoveAll(x => true);
|
||||
// wi.PartRequests.RemoveAll(x => true);
|
||||
// wi.Expenses.RemoveAll(x => true);
|
||||
// wi.Loans.RemoveAll(x => true);
|
||||
// wi.OutsideServices.RemoveAll(x => true);
|
||||
// }
|
||||
|
||||
// //tasks are allowed to be viewed and update the task completion types
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (populateDisplayFields)
|
||||
// await WorkOrderPopulateVizFields(ret, false, populateForReporting);
|
||||
|
||||
// if (logTheGetEvent && ret != null)
|
||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
||||
// }
|
||||
// return ret;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//UPDATE
|
||||
//
|
||||
@@ -464,9 +552,9 @@ namespace AyaNova.Biz
|
||||
private async Task AutoSetAddressAsync(WorkOrder newObj)
|
||||
{
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(newObj.PostAddress) || !string.IsNullOrWhiteSpace(newObj.Address))
|
||||
if (!string.IsNullOrWhiteSpace(newObj.PostAddress) || !string.IsNullOrWhiteSpace(newObj.Address))
|
||||
return;
|
||||
|
||||
|
||||
|
||||
if (newObj.CustomerId == 0)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user