public ActionResult Create(DealerViewModel dealerModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Dealer dealerObj = dbContext.Dealers.Find(dealerModel.Id);
                    if (dealerObj != null)
                    {
                        ModelState.AddModelError("", "The Dealer was created.");
                    }
                    else
                    {
                        Dealer dealerSave = dealerModel.ToDealer(dealerObj);

                        dbContext.Dealers.Add(dealerSave);
                        dbContext.SaveChanges();
                        return(RedirectToAction("Index"));
                    }
                }
            }
            catch (Exception)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, Please se Administrator.");
            }


            return(View(dealerModel));
        }
        public ActionResult Edit(DealerViewModel dealerModel)
        {
            var    dealerToUpdate = dbContext.Dealers.Find(dealerModel.Id);
            Dealer dealerNew      = dealerModel.ToDealer(dealerToUpdate);

            if (dealerToUpdate == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }


            if (ModelState.IsValid)
            {
                try
                {
                    dbContext.Dealers.Attach(dealerNew);
                    dbContext.Entry(dealerNew).State = EntityState.Modified;
                    dbContext.SaveChanges();

                    return(RedirectToAction("Index"));
                }
                catch (RetryLimitExceededException)
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }
            DealerViewModel model = new DealerViewModel(dealerNew);

            return(View(model));
        }