Ejemplo n.º 1
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            if (!_currentUserService.HasGroup(UserGroups.ContractManager))
            {
                throw new UnauthorizedAccessException(Resources.InvalidPermissions);
            }

            WorkOrder workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanApproveVariation();

            var variationJobStatus = await _jobStatusUpdateGateway.GetOutstandingVariation(workOrder.Id);

            var authorised = await _authorizationService.AuthorizeAsync(_currentUserService.GetUser(), variationJobStatus, "VarySpendLimit");

            if (!authorised.Succeeded)
            {
                throw new UnauthorizedAccessException(Resources.VariationApprovalAboveSpendLimit);
            }

            await VaryWorkOrder(workOrder, variationJobStatus);

            jobStatusUpdate.Comments = $"{jobStatusUpdate.Comments} Approved By: {_currentUserService.GetHubUser().Name}";

            await _notifier.Notify(new VariationApproved(variationJobStatus, jobStatusUpdate));

            await _repairsGateway.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanApproveWorkOrder();

            if (!_currentUserService.HasGroup(UserGroups.AuthorisationManager))
            {
                throw new UnauthorizedAccessException(Resources.InvalidPermissions);
            }

            var authorised = await _authorizationService.AuthorizeAsync(_currentUserService.GetUser(), workOrder, "RaiseSpendLimit");

            if (!authorised.Succeeded)
            {
                throw new UnauthorizedAccessException(Resources.WorkOrderApprovalAboveSpendLimit);
            }

            workOrder.StatusCode     = WorkStatusCode.Open;
            jobStatusUpdate.Comments = $"{jobStatusUpdate.Comments} Approved By: {_currentUserService.GetHubUser().Name}";

            await NotifyHandlers(workOrder);
        }
Ejemplo n.º 3
0
 public IActionResult GetHubUser()
 {
     return(Ok(_currentUserService.GetHubUser()));
 }