示例#1
0
 public static AgencyInfo ToAgencyInfo(this Agency agency, ContractKind?contractKind,
                                       AgencyVerificationStates verificationState, DateTime?verificationDate, JsonDocument countryNames, string languageCode, string markupFormula)
 => new AgencyInfo(name: agency.Name,
                   id: agency.Id,
                   address: agency.Address,
                   billingEmail: agency.BillingEmail,
                   city: agency.City,
                   countryCode: agency.CountryCode,
                   countryName: countryNames.RootElement.GetProperty(languageCode).GetString(),
                   fax: agency.Fax,
                   phone: agency.Phone,
                   postalCode: agency.PostalCode,
                   website: agency.Website,
                   vatNumber: agency.VatNumber,
                   defaultPaymentType: BookingPaymentTypesHelper.GetDefaultPaymentType(contractKind),
                   countryHtId: agency.CountryHtId,
                   localityHtId: agency.LocalityHtId,
                   ancestors: agency.Ancestors ?? new List <int>(),
                   verificationState: verificationState,
                   verificationDate: verificationDate,
                   isActive: agency.IsActive,
                   legalAddress: agency.LegalAddress,
                   preferredPaymentMethod: agency.PreferredPaymentMethod,
                   isContractUploaded: agency.IsContractUploaded,
                   markupDisplayFormula: markupFormula,
                   preferredCurrency: agency.PreferredCurrency);
示例#2
0
 public AgencyInfo(string name, int?id, string address, string billingEmail, string city,
                   string countryCode, string countryName, string fax, string phone, string postalCode, string website, string vatNumber,
                   PaymentTypes defaultPaymentType, string countryHtId, string localityHtId, List <int> ancestors,
                   AgencyVerificationStates verificationState, DateTime?verificationDate, bool isActive, string legalAddress, PaymentTypes preferredPaymentMethod,
                   bool isContractUploaded, string markupDisplayFormula, Currencies preferredCurrency)
 {
     Name                   = name;
     Id                     = id;
     Address                = address;
     BillingEmail           = billingEmail;
     City                   = city;
     CountryCode            = countryCode;
     CountryName            = countryName;
     Fax                    = fax;
     Phone                  = phone;
     PostalCode             = postalCode;
     Website                = website;
     VatNumber              = vatNumber;
     DefaultPaymentType     = defaultPaymentType;
     CountryHtId            = countryHtId;
     LocalityHtId           = localityHtId;
     Ancestors              = ancestors;
     VerificationState      = verificationState;
     VerificationDate       = verificationDate;
     IsActive               = isActive;
     LegalAddress           = legalAddress;
     PreferredPaymentMethod = preferredPaymentMethod;
     IsContractUploaded     = isContractUploaded;
     MarkupDisplayFormula   = markupDisplayFormula;
     PreferredCurrency      = preferredCurrency;
 }
示例#3
0
 public SlimAgencyInfo(string name, string address, string billingEmail, string city,
                       string countryCode, string countryName, string fax, string phone, string postalCode, string website,
                       string vatNumber, PaymentTypes defaultPaymentType, List <int> ancestors, string countryHtId, string localityHtId,
                       AgencyVerificationStates verificationState, DateTime?verificationDate, string legalAddress, PaymentTypes preferredPaymentMethod,
                       bool isContractUploaded)
 {
     Name                   = name;
     Address                = address;
     BillingEmail           = billingEmail;
     City                   = city;
     CountryCode            = countryCode;
     CountryName            = countryName;
     Fax                    = fax;
     Phone                  = phone;
     PostalCode             = postalCode;
     Website                = website;
     VatNumber              = vatNumber;
     DefaultPaymentType     = defaultPaymentType;
     Ancestors              = ancestors;
     CountryHtId            = countryHtId;
     LocalityHtId           = localityHtId;
     VerificationState      = verificationState;
     VerificationDate       = verificationDate;
     LegalAddress           = legalAddress;
     PreferredPaymentMethod = preferredPaymentMethod;
     IsContractUploaded     = isContractUploaded;
 }
示例#4
0
 public AgentAgencyRelationInfo(int agencyId, string agencyName, bool isMaster, List <InAgencyPermissions> inAgencyPermissions,
                                AgencyVerificationStates agencyVerificationState, PaymentTypes defaultPaymentType)
 {
     AgencyId                = agencyId;
     AgencyName              = agencyName;
     IsMaster                = isMaster;
     InAgencyPermissions     = inAgencyPermissions;
     AgencyVerificationState = agencyVerificationState;
     DefaultPaymentType      = defaultPaymentType;
 }
        private async Task SetVerificationState(Agency agency, AgencyVerificationStates state, string verificationReason)
        {
            var    now = _dateTimeProvider.UtcNow();
            string reason;

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

            agency.VerificationState  = state;
            agency.VerificationReason = reason;
            agency.Verified           = now;
            agency.Modified           = now;
            _context.Update(agency);
            await _context.SaveChangesAsync();

            await SendNotificationToMaster();


            async Task <Result> SendNotificationToMaster()
            {
                var(_, isFailure, master, error) = await _agentService.GetMasterAgent(agency.Id);

                if (isFailure)
                {
                    return(Result.Failure(error));
                }

                var messageData = new AgencyVerificationStateChangedData
                {
                    AgentName  = $"{master.FirstName} {master.LastName}",
                    AgencyName = agency.Name,
                    State      = EnumFormatters.FromDescription(state),
                };

                return(await _notificationService.Send(agent : new SlimAgentContext(master.Id, agency.Id),
                                                       messageData : messageData,
                                                       notificationType : NotificationTypes.AgencyVerificationChanged,
                                                       email : master.Email));
            }
        }
示例#6
0
        private static List <InAgencyPermissions> GetActualPermissions(AgencyVerificationStates agencyVerificationState, InAgencyPermissions inAgencyPermissions)
        {
            const InAgencyPermissions readOnlyPermissions = InAgencyPermissions.AccommodationAvailabilitySearch |
                                                            InAgencyPermissions.AgentInvitation |
                                                            InAgencyPermissions.PermissionManagement |
                                                            InAgencyPermissions.ObserveAgents;

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

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

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

            default:
                throw new ArgumentException($"Invalid agency verification state {agencyVerificationState}");
            }
        }
示例#7
0
        private static List <InAgencyPermissions> GetActualPermissions(AgencyVerificationStates agencyVerificationState, int[] roleIds, List <AgentRole> roles)
        {
            var permissions = GetInAgencyPermissions(roleIds, roles);

            return(GetActualPermissions(agencyVerificationState, permissions));
        }
 public MinAgencyVerificationStateAuthorizationRequirement(AgencyVerificationStates agencyVerificationState)
 {
     AgencyVerificationState = agencyVerificationState;
 }
示例#9
0
 public MinAgencyVerificationStateAttribute(AgencyVerificationStates minimalState)
 {
     Policy = $"{PolicyPrefix}{minimalState}";
 }
 private Task WriteVerificationToAuditLog(int agencyId, string verificationReason, AgencyVerificationStates verificationState)
 => _managementAuditService.Write(ManagementEventType.AgencyVerification,
                                  new AgencyVerifiedEventData(agencyId, verificationReason, verificationState));
示例#11
0
 public AgencyVerifiedEventData(int agencyId, string reason, AgencyVerificationStates verificationState)
 {
     AgencyId          = agencyId;
     Reason            = reason;
     VerificationState = verificationState;
 }