Ejemplo n.º 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);
Ejemplo n.º 2
0
        public async Task <List <AgentAgencyRelationInfo> > GetAgentRelations(AgentContext agent)
        {
            var roles = await _context.AgentRoles.ToListAsync();

            return(await(from cr in _context.AgentAgencyRelations
                         join ag in _context.Agencies
                         on cr.AgencyId equals ag.Id
                         join ra in _context.Agencies
                         on ag.Ancestors.Any() ? ag.Ancestors[0] : ag.Id equals ra.Id
                         where ag.IsActive && cr.AgentId == agent.AgentId
                         select new AgentAgencyRelationInfo(
                             ag.Id,
                             ag.Name,
                             cr.Type == AgentAgencyRelationTypes.Master,
                             GetActualPermissions(ra.VerificationState, cr.AgentRoleIds, roles),
                             ra.VerificationState,
                             BookingPaymentTypesHelper.GetDefaultPaymentType(ra.ContractKind)))
                   .ToListAsync());
        }