public async Task <IActionResult> Create(FactoryDataModel obj) { FactoryService fs = new FactoryService(_con); var y = fs.GetFactoryByName(obj.Name); if (y != null) { ViewBag.Business = fs.GetallBusinessType(); ModelState.AddModelError("Name", "Name is already exist"); return(View(obj)); } bool x = await fs.CreateFactory(obj); return(RedirectToAction(nameof(Index))); }