public async Task <IActionResult> Get([FromQuery(Name = "tenancy_refs")] List <string> tenancyRefs)
        {
            var response  = listTenancies.Execute(tenancyRefs);
            var tenancies = response.Tenancies.ConvertAll(tenancy => new Dictionary <string, object>
            {
                { "ref", tenancy.TenancyRef },
                { "prop_ref", tenancy.PropertyRef },
                { "tenure", tenancy.Tenure },
                { "current_balance", tenancy.CurrentBalance },
                { "current_arrears_agreement_status", tenancy.ArrearsAgreementStatus },
                {
                    "latest_action", new Dictionary <string, string>
                    {
                        { "code", tenancy.LastActionCode },
                        { "date", tenancy.LastActionDate }
                    }
                },
                {
                    "primary_contact", new Dictionary <string, string>
                    {
                        { "name", tenancy.PrimaryContactName },
                        { "short_address", tenancy.PrimaryContactShortAddress },
                        { "postcode", tenancy.PrimaryContactPostcode }
                    }
                }
            });

            var result = new Dictionary <string, object>
            {
                { "tenancies", tenancies }
            };

            return(Ok(result));
        }
Beispiel #2
0
 public IActionResult ListTenancies([FromQuery] QueryParameters queryParameters)
 {
     try
     {
         return(Ok(_listTenancies.Execute(queryParameters.Limit, queryParameters.Cursor,
                                          queryParameters.Address, queryParameters.Postcode, queryParameters.LeaseholdsOnly,
                                          queryParameters.FreeholdsOnly, queryParameters.PropertyReference)));
     }
     catch (InvalidQueryParameterException exception)
     {
         return(BadRequest(exception.Message));
     }
 }