Пример #1
0
 public AgentAgencyRelationInfo(int id, string name, int agencyId, string agencyName, bool isMaster, List <InAgencyPermissions> inAgencyPermissions, CounterpartyStates counterpartyState)
 {
     Id                  = id;
     Name                = name;
     AgencyId            = agencyId;
     AgencyName          = agencyName;
     IsMaster            = isMaster;
     InAgencyPermissions = inAgencyPermissions;
     CounterpartyState   = counterpartyState;
 }
        private Task SetVerificationState(Counterparty counterparty, CounterpartyStates state, string verificationReason)
        {
            var    now = _dateTimeProvider.UtcNow();
            string reason;

            if (string.IsNullOrEmpty(counterparty.VerificationReason))
            {
                reason = verificationReason;
            }
            else
            {
                reason = counterparty.VerificationReason + Environment.NewLine + verificationReason;
            }

            counterparty.State = state;
            counterparty.VerificationReason = reason;
            counterparty.Verified           = now;
            counterparty.Updated            = now;
            _context.Update(counterparty);

            return(_context.SaveChangesAsync());
        }
        public async Task <Result> Verify(int counterpartyId, CounterpartyStates state, string reason)
        {
            if (string.IsNullOrWhiteSpace(reason))
            {
                return(Result.Failure("Verification reason cannot be empty"));
            }

            switch (state)
            {
            case CounterpartyStates.FullAccess:
                return(await VerifyAsFullyAccessed(counterpartyId, reason));

            case CounterpartyStates.ReadOnly:
                return(await VerifyAsReadOnly(counterpartyId, reason));

            case CounterpartyStates.DeclinedVerification:
                return(await DeclineVerification(counterpartyId, reason));

            default:
                return(Result.Failure("Invalid verification state"));
            }
        }
Пример #4
0
        private static List <InAgencyPermissions> GetActualPermissions(CounterpartyStates counterpartyState, InAgencyPermissions inAgencyPermissions)
        {
            const InAgencyPermissions readOnlyPermissions = InAgencyPermissions.AccommodationAvailabilitySearch |
                                                            InAgencyPermissions.AgentInvitation |
                                                            InAgencyPermissions.PermissionManagement |
                                                            InAgencyPermissions.ObserveAgents;

            switch (counterpartyState)
            {
            case CounterpartyStates.DeclinedVerification:
            case CounterpartyStates.PendingVerification:
                return(new List <InAgencyPermissions>(0));

            case CounterpartyStates.ReadOnly:
                return((inAgencyPermissions & readOnlyPermissions).ToList());

            case CounterpartyStates.FullAccess:
                return(inAgencyPermissions.ToList());

            default:
                throw new ArgumentException($"Invalid counterparty state {counterpartyState}");
            }
        }
 public CounterpartyVerificationRequest(CounterpartyStates state, string reason)
 {
     State  = state;
     Reason = reason;
 }
 public MinCounterpartyStateAuthorizationRequirement(CounterpartyStates counterpartyState)
 {
     CounterpartyState = counterpartyState;
 }
 public MinCounterpartyStateAttribute(CounterpartyStates minimalState)
 {
     Policy = $"{PolicyPrefix}{minimalState}";
 }