public async Task <IActionResult> RegisterInsurenceClaim(CreateInsurenceClaimViewModel viewModel)
        {
            CreateInsurenceClaimRequest request = new CreateInsurenceClaimRequest()
            {
                DriverCPF            = viewModel.DriverCPF,
                InsurenceId          = viewModel.InsurenceId,
                InsurenceClaimDate   = viewModel.InsurenceClaimDate,
                OccurrenceNumber     = viewModel.OccurrenceNumber,
                Observation          = viewModel.Observation,
                InsurenceClaimNumber = viewModel.InsurenceClaimNumber,
                InsurenceClaimType   = viewModel.InsurenceClaimType,

                CEP          = viewModel.CEP,
                Street       = viewModel.Street,
                Number       = viewModel.Number,
                Neighborhood = viewModel.Neighborhood,
                City         = viewModel.City,
                UF           = viewModel.UF,
            };

            if (await _movtechAPIService.CreateInsurenceClaim(request))
            {
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                ModelState.AddModelError("", "Não foi possível Criar o Seguro ");


                viewModel.Insurences = await _movtechAPIService.GetAllInsurences();

                return(View("Create", viewModel));
            }
        }
Ejemplo n.º 2
0
        public async Task <bool> CreateInsurenceClaim(CreateInsurenceClaimRequest request)
        {
            try
            {
                HttpResponseMessage _message = await _client.PostAsync("api/v1/InsurenceClaims",
                                                                       new StringContent(JsonConvert.SerializeObject(request),
                                                                                         Encoding.UTF8, "application/json"));

                return(_message.IsSuccessStatusCode);
            }
            catch (Exception ex)
            {
                throw;
            }
        }