public ActionResult Parse(string brand = null) { ExistParser exist = new ExistParser(); if (!string.IsNullOrWhiteSpace(brand)) { var listuri = exist.Parse(brand); foreach (var node in listuri) { var anyUser = Repository.CarModelss.Where(p => string.Compare(p.BrandName, node.BrandName) == 0 && string.Compare(p.ModelName, node.ModelName) == 0).Count(); if (anyUser > 0) { ModelState.AddModelError("ModelName", "Такая модель уже зарегестрирована "); } else { ModelState.Remove("ModelName"); } if (ModelState.IsValid) { var CarModels = node; Repository.CreateCarModel(CarModels); } } return(View(listuri)); } return(View()); }
// GET: Test //public ActionResult Index() //{ // var carmodels = Repository.CarModelss.ToList(); // return View(carmodels); //} public ActionResult Index(int page = 1) { ExistParser pasd = new ExistParser(); pasd.Parse("Tesla"); ViewData.Add("List", Repository.CarModelss); var data = new PageableData <CarModels>(Repository.CarModelss, page, 30); return(View(data)); }