public async Task <IActionResult> Delete(CarListWithViewModels model)
        {
            var carId           = model.Id;
            var password        = model.Password;
            var user            = this.userServices.GetUserByCarId(carId);
            var isPasswordValid = false;

            if (password != null)
            {
                isPasswordValid = await userManager.CheckPasswordAsync(this.mapper.Map <ApplicationUser>(user), password);
            }

            if (this.ModelState.IsValid && isPasswordValid)
            {
                await this.carServices.DeleteCarAsync(model.Id);

                return(RedirectToAction("ListCars", "Car"));
            }
            else
            {
                if (isPasswordValid == false)
                {
                    ModelState.AddModelError(string.Empty, "Ivalid Password!");
                    return(this.RedirectToAction("ListCars", "Car"));
                }
                else
                {
                    return(RedirectToAction("ListCars", "Car"));
                }
            }
        }
        public IActionResult ListAllCars()
        {
            var carsFromDb = this.carServices.GetAllCars();

            var carListingViewModels = carsFromDb.Select(car => this.mapper.Map <CarListingViewModel>(car));


            var cars = new CarListWithViewModels()
            {
                Cars = carListingViewModels
            };

            return(this.View(cars));
        }
        public IActionResult ListCars()
        {
            var user = this.userServices.GetUserByName(this.User.Identity.Name);

            var carsFromDb = this.carServices.GetAllCarsForUserWithId(user.Id);

            if (carsFromDb != null)
            {
                var cars = carsFromDb.Select(car => this.mapper.Map <CarListingViewModel>(car));

                var carsBinding = new CarListWithViewModels()
                {
                    Cars = cars
                };

                return(this.View(carsBinding));
            }
            else
            {
                return(this.View());
            }
        }