public ActionResult Carro()
        {
            CarroCliente carroCliente = new CarroCliente();

            ViewBag.Status = "";
            CarroRetorno retorno = new CarroRetorno();
            Usuario      usuario = new Usuario();
            var          task    = Task.Run(async() => {
                token_ = await GetToken();

                using (BaseController <CarroRetorno> bCarro = new BaseController <CarroRetorno>())
                {
                    var valorRetorno = await bCarro.GetObjectAsyncWithToken("Carros/BuscarCarroCliente/" + GetIdPessoa(), token_);
                    retorno          = valorRetorno.Data;
                }
                using (BaseController <Usuario> bUsuario = new BaseController <Usuario>())
                {
                    var valorRetorno = await bUsuario.GetObjectAsyncWithToken("Usuarios/Detalhes/" + GetIdUsuario(), token_);
                    usuario          = valorRetorno.Data;
                }
            });

            task.Wait();

            if (retorno != null && retorno.IdMarca > 0)
            {
                carroCliente = new CarroCliente
                {
                    IdMarca = retorno.IdMarca,
                    Modelo  = retorno.Modelo,
                    Placa   = retorno.Placa,
                    Porte   = retorno.Porte
                };
                ViewBag.Status = "Update";
            }
            else
            {
                ViewBag.Status = "Register";
            }
            ViewBag.Cadastrar     = "You need to register a car. click here.";
            ViewBag.Nickname      = retorno.Nome;
            ViewBag.InsereAlerta  = retorno.Alerta;
            ViewBag.InsereAlerta2 = false;
            ViewBag.InsereAlerta3 = false;
            ViewBag.Level         = retorno.Level;
            ViewData["foto"]      = usuario.Foto;

            ViewBag.Marcas = Helpers.GetSelectList("Marcas", token_) as SelectList;
            return(View(carroCliente));
        }
        public JsonResult RegistrarCarro(CarroCliente carroCliente)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ResponseViewModel <CarroCliente> responseViewModel = new ResponseViewModel <CarroCliente>();
                    carroCliente.IdCliente = GetIdPessoa();
                    var task = Task.Run(async() => {
                        using (BaseController <CarroCliente> baseController = new BaseController <CarroCliente>())
                        {
                            var retorno       = await baseController.PostWithToken(carroCliente, "Carros/Registrar", await GetToken());
                            responseViewModel = retorno;
                        }
                    });
                    task.Wait();
                    return(Json(responseViewModel));
                }
                else
                {
                    ResponseViewModel <CarroCliente> responseViewModel = new ResponseViewModel <CarroCliente>
                    {
                        Data        = carroCliente,
                        Mensagem    = "Dados inválidos.",
                        Serializado = true,
                        Sucesso     = false
                    };

                    return(Json(responseViewModel, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                ResponseViewModel <CarroCliente> responseViewModel = new ResponseViewModel <CarroCliente>
                {
                    Data        = carroCliente,
                    Mensagem    = "Ocorreu um erro ao processar sua solicitação.",
                    Serializado = true,
                    Sucesso     = false
                };

                return(Json(responseViewModel, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Carro()
        {
            CarroCliente carroCliente = new CarroCliente();

            ViewBag.Status = "";
            CarroRetorno retorno = new CarroRetorno();
            var          task    = Task.Run(async() => {
                token_ = await GetToken();

                using (BaseController <CarroRetorno> bCarro = new BaseController <CarroRetorno>())
                {
                    var valorRetorno = await bCarro.GetObjectAsyncWithToken("Carros/BuscarCarroCliente/" + GetIdPessoa(), token_);
                    retorno          = valorRetorno.Data;
                }
            });

            task.Wait();

            if (retorno != null && retorno.IdMarca > 0)
            {
                carroCliente = new CarroCliente
                {
                    IdMarca = retorno.IdMarca,
                    Modelo  = retorno.Modelo,
                    Placa   = retorno.Placa,
                    Porte   = retorno.Porte
                };
                ViewBag.Status = "Atualizar";
            }
            else
            {
                ViewBag.Status = "Cadastrar";
            }
            ViewBag.Nickname      = retorno.Nome;
            ViewBag.InsereAlerta  = retorno.Alerta;
            ViewBag.InsereAlerta2 = false;
            ViewBag.InsereAlerta3 = false;
            ViewBag.Level         = retorno.Level;

            ViewBag.Marcas = Helpers.GetSelectList("Marcas", token_) as SelectList;
            return(View(carroCliente));
        }