예제 #1
0
        public ActionResult Create(CarModelViewModel car)
        {
            var Model = repository.CheckDuplicate(car.Title);

            if (Model)
            {
                var list = manufactureRepository.GetList()
                           .Select(x => new SelectListItem
                {
                    Text  = x.Title,
                    Value = x.ID.ToString()
                }).ToList();
                list.Insert(0, new SelectListItem {
                    Value = "", Text = "انتخاب نمایید"
                });
                ViewBag.ManufactureList = list;
                ViewBag.ErrorMessage    = "عنوان وارد شده تکراریست";
                return(View());
            }
            repository.Create(car);
            return(RedirectToAction("Index"));
        }