예제 #1
0
        private async Task <List <BenefitsDocument> > GetDocuments(string personReference)
        {
            var response = await _civicaServiceGateway.GetDocuments(personReference);

            var documents = response.Parse <List <CouncilTaxDocument> >().ResponseContent;

            return(documents?.MapToDocuments().Where(_ => _.Type == "Notif").ToList() ?? new List <BenefitsDocument>());
        }
        public async Task <CouncilTaxDetailsModel> GetCouncilTaxDetails(
            string personReference,
            string accountReference,
            int year)
        {
            var key           = $"{personReference}-{accountReference}-{year}-{CacheKeys.CouncilTaxDetails}";
            var cacheResponse = await _cacheProvider.GetStringAsync(key);

            if (!string.IsNullOrEmpty(cacheResponse))
            {
                var cachedResponse = JsonConvert.DeserializeObject <CouncilTaxDetailsModel>(cacheResponse);
                return(cachedResponse);
            }

            var model = new CouncilTaxDetailsModel();

            var accountResponse = await _gateway.GetAccount(personReference, accountReference);

            model = accountResponse.Parse <CouncilTaxAccountResponse>().ResponseContent.MapAccount(model, year);

            var accountsResponse = await _gateway.GetAccounts(personReference);

            model = accountsResponse.Parse <List <CtaxActDetails> >().ResponseContent.MapAccounts(model);

            var transactionsResponse = await _gateway.GetAllTransactionsForYear(personReference, accountReference, year);

            model = transactionsResponse.Parse <List <Transaction> >().ResponseContent.MapTransactions(model);

            var paymentResponse = await _gateway.GetPaymentSchedule(personReference, year);

            model = paymentResponse.Parse <List <Installment> >().ResponseContent.MapPayments(model);

            var currentPropertyResponse = await _gateway.GetCurrentProperty(personReference, accountReference);

            model = currentPropertyResponse.Parse <Place>().ResponseContent.MapCurrentProperty(model);

            var documentsResponse = await _gateway.GetDocuments(personReference);

            model = documentsResponse.Parse <List <CouncilTaxDocumentReference> >().ResponseContent.DocumentsMapper(model, year);

            var isBenefitsResponse = await _gateway.IsBenefitsClaimant(personReference);

            model.HasBenefits = isBenefitsResponse.Parse <bool>().ResponseContent;

            _ = _cacheProvider.SetStringAsync(key, JsonConvert.SerializeObject(model));

            return(model);
        }