public async Task <ActionResult> CalcularPremioSeguro([FromBody] SeguradoSearchDto segurado)
        {
            List <IFilter>   filters          = null;
            CalculoSeguroDto calculoSeguroDto = null;

            try
            {
                calculoSeguroDto = new CalculoSeguroDto();
                //Selecionar veículos segurado
                filters = new List <IFilter>();
                filters.Add(new FilterObj {
                    FilterName = "numerocpf", FilterValue = segurado.NumeroCPF
                });
                calculoSeguroDto.ListVeiculo = await _veiculoService.GetByFilter(filters);;
                //Selecionar segurado
                filters = new List <IFilter>();
                filters.Add(new FilterObj {
                    FilterName = "numerocpf", FilterValue = segurado.NumeroCPF
                });
                calculoSeguroDto.Segurado = await _seguradoService.GetSingle(filters);

                var result = await _seguroVeiculoService.CalcularSeguro(calculoSeguroDto);

                string urlGetCalculos = "/CalculoSeguroList";
                var    resultAction   = new ResultAction("Calculo incluído com sucesso", true, urlGetCalculos);
                return(Created(new Uri(urlGetCalculos), resultAction));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> GetVeiculos([FromBody] VeiculoSearchDto veiculo)
        {
            List <IFilter> filters = null;

            try
            {
                filters = new List <IFilter>();
                filters.Add(new FilterObj {
                    FilterName = "numerocpf", FilterValue = veiculo.NumeroCPF
                });
                return(Ok(await _veiculoService.GetByFilter(filters)));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemplo n.º 3
0
        public async void UnitTestCalculoPremio()
        {
            List <IFilter>   filters          = null;
            CalculoSeguroDto calculoSeguroDto = null;
            var result = default(object);
            SeguradoSearchDto segurado = null;

            try
            {
                using (var service = _services.BuildServiceProvider())
                {
                    calculoSeguroDto = new CalculoSeguroDto();
                    segurado         = new SeguradoSearchDto {
                        NumeroCPF = "70769777619"
                    };

                    veiculoService       = service.GetService <IVeiculoService>();
                    seguradoService      = service.GetService <ISeguradoService>();
                    seguroVeiculoService = service.GetService <ISeguroVeiculoService>();

                    //Selecionar veículos segurado
                    filters = new List <IFilter>();
                    filters.Add(new FilterObj {
                        FilterName = "numerocpf", FilterValue = segurado.NumeroCPF
                    });
                    calculoSeguroDto.ListVeiculo = await veiculoService.GetByFilter(filters);;
                    //Selecionar segurado
                    filters = new List <IFilter>();
                    filters.Add(new FilterObj {
                        FilterName = "numerocpf", FilterValue = segurado.NumeroCPF
                    });
                    calculoSeguroDto.Segurado = await seguradoService.GetSingle(filters);

                    result = await seguroVeiculoService.CalcularSeguro(calculoSeguroDto);
                }
                Assert.AreEqual(true, result != null);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }