public ActionResult AddEditStationLink(AddEditStationLinkViewModel viewModel) { if (!(viewModel.StationId.HasValue)) { var dataTable = CRCDataAccess.GetStationLinkStatus(viewModel.UserId, viewModel.StationId); if (dataTable.Rows.Count != 0) { ModelState.AddModelError("StationId", "This user is already linked to this station."); return(PartialView(viewModel)); // return Json(true); } } //if (viewModel.PrimaryUserInd) //{ // var dataTable = CRCDataAccess.GetStationLinkPrimaryUser(viewModel.StationId); // if (dataTable.Rows.Count != 0) // { // string name = ""; // foreach (System.Data.DataRow dr in dataTable.Rows) // { // name = name + dr["FirstName"].ToString() + " " + dr["MiddleName"].ToString() + " " + dr["LastName"].ToString() + " is the current primary user. Only one user may be designated the primary user for this station."; // } // ModelState.AddModelError("", name); // return PartialView(viewModel); // } //} if (ModelState.IsValid) { if (viewModel.PrimaryUserInd) { viewModel.GridWritePermissionsInd = true; } CRCDataAccess.SaveStationUser(viewModel.StationId.Value, viewModel.UserId, viewModel.PrimaryUserInd, viewModel.GridWritePermissionsInd, CRCUser.UserId); return(Json(true)); } else { return(PartialView(viewModel)); } return(PartialView(viewModel)); }