public async Task <IActionResult> Update(VehicleVM vehicleVM, AppUserVM appUserVM, CustomerVM customerVM, string makeName, string modelName)
        {
            vehicleVM.MakeVM = new MakeVM
            {
                Name = makeName
            };
            vehicleVM.ModelVM = new ModelVM
            {
                Name = modelName
            };
            var vehicleModelMVC = new VehicleModelMVC
            {
                Id         = vehicleVM.Id,
                CreateAt   = vehicleVM.CreateAt,
                CustomerVM = customerVM,
                MakeVM     = vehicleVM.MakeVM,
                ModelVM    = vehicleVM.ModelVM,
                AppUserVM  = appUserVM,
                Odometer   = vehicleVM.Odometer,
                VIN        = vehicleVM.VIN,
                Engine     = vehicleVM.Engine
            };
            string token = HttpContext.Session.GetString("token_access");

            return(View(await listChosen(token, vehicleModelMVC)));
        }
        private async Task <VehicleVM> listChosen(string token, VehicleModelMVC vehicleModelMVC)
        {
            var customers = await _customerServiceApiClient.GetAll(token);

            var makes = await _makeServiceApiClient.GetAll(token);

            var models = await _modelServiceApiClient.GetAll(token);

            var appusers = await _userServiceApiClient.GetAll(token);

            vehicleModelMVC.CustomerVMs = customers;
            vehicleModelMVC.MakeVMs     = makes;
            vehicleModelMVC.ModelVMs    = models;
            vehicleModelMVC.AppUserVMs  = appusers.Select(x => x.appUserVM).ToList();
            return(vehicleModelMVC);
        }
        public async Task <IActionResult> UpdateAction(VehicleModelMVC vehicleModelMVC)
        {
            string token = HttpContext.Session.GetString("token_access");

            if (ModelState.IsValid)
            {
                var result = await _vehicleServiceApiClient.Update(vehicleModelMVC, token);

                if (result.IsSuccessed == true)
                {
                    TempData["SuccessResult"] = result.Entity;
                    return(RedirectToAction("GetAll", "vehicle"));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                    return(View("Update", await listChosen(token, vehicleModelMVC)));
                }
            }
            else
            {
                return(View("Update", await listChosen(token, vehicleModelMVC)));
            }
        }