Пример #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 <GetVariationResponse> Execute(int workOrderId)
        {
            var workOrder = await _repairsGateway.GetWorkOrder(workOrderId);

            workOrder.VerifyCanGetVariation();

            var workOrderTasks = workOrder.WorkElements.SelectMany(we => we.RateScheduleItem);
            var variation      = await _jobStatusUpdateGateway.GetOutstandingVariation(workOrderId);

            var variationTasks = variation.MoreSpecificSORCode.RateScheduleItem;

            return(new GetVariationResponse
            {
                Notes = variation.Comments,
                Tasks = MapTasks(variationTasks, workOrderTasks),
                AuthorName = variation.AuthorName,
                VariationDate = variation.EventTime ?? DateTime.UtcNow
            });
        }
Пример #3
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();
        }