public ActionResult Index(RegionViewModel regionViewModel) { try { if (ModelState.IsValid) { bool isDuplicate = false; isDuplicate = regionViewModel.CheckDuplicate(regionViewModel); if (isDuplicate) { regionViewModel.GetRegionDetails(); ViewBag.Message = "Region Already Exists"; return(View("Index", regionViewModel)); } else { regionViewModel.Region = regionViewModel.Region == null ? "" : regionViewModel.Region.Trim(); regionViewModel.AddRegion(regionViewModel); regionViewModel.GetRegionDetails(); ViewBag.Message = "New Region Added Successfully"; return(View("Index", regionViewModel)); } } regionViewModel.GetRegionDetails(); return(View(regionViewModel)); } catch (Exception ex) { errorlogviewmodel = new ErrorLogViewModel(); errorlogviewmodel.LogError(ex); return(View("Error")); } }