public IActionResult AddCarType(CarType carType) { if (ModelState.IsValid) { var check = _repository.GetAllCarTypes() .Where(q => q.Make == carType.Make && q.Model == carType.Model); if (check.Count() > 0) { ViewBag.CarType = "Car Model already exists!"; } else { _repository.AddCarType(carType); if (_repository.SaveChanges()) { ViewBag.CarType = "Successfull!"; ModelState.Clear(); } else { ViewBag.CarType = "Oops! Could not save data"; } } } return(View()); }