示例#1
0
        private bool ChangeApproval(ApprovalRequest request, Guid statusId)
        {
            if (request == null)
            {
                return(false);
            }
            var action = ClassFactory.Get <ApprovalAction>(new ConstructorArgument("userConnection", UserConnection));

            if (request.AdditionalColumnValues == null)
            {
                request.AdditionalColumnValues = new Dictionary <string, object>();
            }
            request.AdditionalColumnValues.Add("StatusId", statusId);
            return(action.ChangeApproval(request.SchemaName, request.Id, request.AdditionalColumnValues));
        }
        private Dictionary <string, object> GenerateAdditionalColumnValues(ApprovalRequest request,
                                                                           Dictionary <string, object> extraValues = null)
        {
            var additionalColumnValues = request.AdditionalColumnValues ?? new Dictionary <string, object>();

            request.AdditionalValues?.ForEach(item => {
                if (!additionalColumnValues.ContainsKey(item.Key))
                {
                    additionalColumnValues.Add(item.Key, item.Value);
                }
            });
            extraValues?.ForEach(item => {
                if (!additionalColumnValues.ContainsKey(item.Key))
                {
                    additionalColumnValues.Add(item.Key, item.Value);
                }
            });
            return(additionalColumnValues);
        }
        private BaseResponse ChangeApprovalWithResponse(ApprovalRequest request, Guid statusId)
        {
            var response = new BaseResponse()
            {
                Success   = false,
                ErrorInfo = new ErrorInfo()
                {
                    Message = $"Exception: Unexpected exception."
                }
            };

            if (request == null)
            {
                response.ErrorInfo.Message = "Exception: Approval request is empty.";
                return(response);
            }
            try {
                var action = ClassFactory.Get <IApprovalAction>(new ConstructorArgument("userConnection", UserConnection));
                request.AdditionalColumnValues = GenerateAdditionalColumnValues(request,
                                                                                new Dictionary <string, object>()
                {
                    { "StatusId", statusId }
                });
                response.Success = action.ChangeApprovalWithLocationException(request.SchemaName, request.Id,
                                                                              request.AdditionalColumnValues);
            } catch (VisaNotFoundException) {
                response.ErrorInfo.Message = "Exception: Visa not found.";
            } catch (VisaFinalStatusException) {
                response.ErrorInfo.Message = "Exception: Visa has final status.";
            } catch (SaveVisaChangesException) {
                response.ErrorInfo.Message = "Exception: Visa changes didn't save.";
            } catch (Exception e) {
                response.ErrorInfo.Message = $"Exception: {e.Message}";
            }
            return(response);
        }
示例#4
0
 public bool Reject(ApprovalRequest request)
 {
     return(ChangeApproval(request, ApprovalConstants.Rejected));
 }
示例#5
0
 public bool Approve(ApprovalRequest request)
 {
     return(ChangeApproval(request, ApprovalConstants.Accepted));
 }
 public BaseResponse RejectWithResponse(ApprovalRequest request)
 {
     return(ChangeApprovalWithResponse(request, ApprovalConstants.Rejected));
 }
 public BaseResponse ApproveWithResponse(ApprovalRequest request)
 {
     return(ChangeApprovalWithResponse(request, ApprovalConstants.Accepted));
 }