Example #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();
        }
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanAcknowledgeVariation();

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

            workOrder.StatusCode = WorkStatusCode.Open;
            await _repairsGateway.SaveChangesAsync();
        }
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanRejectWorkOrder();

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

            workOrder.StatusCode = WorkStatusCode.Canceled;
            jobStatusUpdate.PrefixComments(Resources.WorkOrderAuthorisationRejected);

            await _notifier.Notify(new WorkOrderRejected(workOrder));
        }
Example #4
0
        public async Task Execute(JobStatusUpdate jobStatusUpdate)
        {
            var workOrder = jobStatusUpdate.RelatedWorkOrder;

            workOrder.VerifyCanRejectVariation();

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

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

            workOrder.StatusCode = WorkStatusCode.VariationRejected;
            jobStatusUpdate.PrefixComments(Resources.RejectedVariationPrepend);

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

            await _repairsGateway.SaveChangesAsync();
        }
Example #5
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);
        }
 private bool CanUserComplete(WorkOrder workOrder)
 {
     return(_currentUserService.HasGroup(UserGroups.Contractor) ||
            _currentUserService.HasGroup(UserGroups.ContractManager) ||
            workOrder.IsAssignedOperative(_currentUserService));
 }