public ActionResult Create(UserType usertype) { try { // TODO: Add insert logic here if (ModelState.IsValid) { var getusertypename = UsertypeService.GetUserByName(usertype.UserTypeName); if (getusertypename == null) { UsertypeService.Insert(usertype); UsertypeService.SaveChange(); return(RedirectToAction("Index")); } ViewBag.Error = "User Already Exist"; return(View(usertype)); } return(View(usertype)); } catch { return(View(usertype)); } }