public ActionResult Roles(SMSA_Roles_ST Roles) { try { string strMessage = ""; bool _success = false; if (Roles.RoleId == null || Roles.RoleId.ToString() == "{00000000-0000-0000-0000-000000000000}") { if (System.Web.Security.Roles.RoleExists(Roles.RoleName)) { strMessage = "Role already exists"; return(Json(new { success = false, response = strMessage })); } System.Web.Security.Roles.CreateRole(Roles.RoleName); int maxValue = dbUser.InsertRoles(Roles); Roles.RoleId = maxValue.ToString(); if (maxValue > 0) { strMessage = "Record successfully saved."; _success = true; } else { strMessage = "Application server error."; } } else { int maxValue = dbUser.UpdateRoles(Roles); if (maxValue > 0) { strMessage = "Record successfully updated."; _success = true; } else { strMessage = "Application server error."; } } return(Json(new { success = _success, response = strMessage })); } catch (Exception ex) { Log.LogWrite(ex.Message, "Roles Insert/Edit", ex); return(Json(new { success = false, response = ex.Message.ToString() })); } }