public async Task <IActionResult> Details(int id)
        {
            return(await _resiliencyHelper.ExecuteResilient(async() =>
            {
                var insurance = await _vehicleManagementAPI.GeInsuranceById(id);

                var vehicle = await _vehicleManagementAPI.GetVehicleByCode(insurance.VehicleId.ToString());

                var model = new VehicleInsuranceManagementDetailsViewModel
                {
                    Insurance = insurance,
                    Vehicle = vehicle
                };
                return View(model);
            }, View("Offline", new VehicleInsuranceManagementOfflineViewModel())));
        }
Exemple #2
0
 public async Task <Insurance> GeInsuranceById([AliasAs("id")] int insuranceId)
 {
     try
     {
         return(await _client.GeInsuranceById(insuranceId));
     }
     catch (ApiException ex)
     {
         if (ex.StatusCode == HttpStatusCode.NotFound)
         {
             return(null);
         }
         else
         {
             throw;
         }
     }
 }
        public async Task <IActionResult> Details(int id)
        {
            return(await _resiliencyHelper.ExecuteResilient(async() =>
            {
                var insurance = await _vehicleManagementAPI.GeInsuranceById(id);
                var vehicle = await _vehicleManagementAPI.GetVehicleByCode(insurance.VehicleId.ToString());
                var vehicles = await _vehicleManagementAPI.GetVehicles();

                var model = new VehicleInsuranceManagementDetailsViewModel
                {
                    Insurance = insurance,
                    Vehicle = vehicle,
                    Vehicles = vehicles.Select(c => new SelectListItem {
                        Value = c.Codigo.ToString(), Text = c.Matricula
                    })
                };
                return View(model);
            }, View("Offline", new VehicleInsuranceManagementOfflineViewModel())));
        }