Пример #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;
 }
Пример #5
0
        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}";
 }
Пример #10
0
 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;
 }