public ActionResult Edit(string id) { int idNo = Convert.ToInt32(id); RoleRPS role = RoleRPS.GetRole(idNo); return(View(role)); }
public ActionResult Welcome() { string user = User.Identity.Name; RoleRPS role = new RoleRPS { ID = 1, Name = "database_admin" }; return(Json(role, JsonRequestBehavior.AllowGet)); }
// GET: Role public ActionResult Index(string msg) { if (!string.IsNullOrEmpty(msg)) { ViewBag.Message = msg; } IEnumerable <RoleRPS> result = RoleRPS.GetRoles(); return(View(result)); }
public int CreateRole(RoleRPS rle) { string sqlString = " INSERT INTO [ROLES] (NAME, ISDEFAULT, ISACTIVE) VALUES (@RoleName,1,1);"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@RoleName", rle.Name) }; return(ExecNonQuery(sqlString, param)); }
public ActionResult Create(RoleRPS role) { if (ModelState.IsValid) { role.Create(); ViewBag.Message = "Created role successfully."; return(RedirectToAction("Index", new { msg = "Created role successfully." })); } ViewBag.Message = "Error in creating Role"; return(View(role)); }
public ActionResult Edit(RoleRPS role) { if (ModelState.IsValid) { //Save changes role.Update(); ViewBag.Message = "updated Role successfully"; return(View(role)); } ViewBag.Message = "Failed to update Role"; return(View(role)); }
public int UpdateRole(RoleRPS rle) { string sqlString = "UPDATE ROLES SET NAME = @RoleName, ISACTIVE = @IsActive WHERE ID = @Id;"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@RoleName", rle.Name), new SqlParameter("@IsActive", rle.IsActive), new SqlParameter("@Id", rle.ID) }; return(ExecNonQuery(sqlString, param)); }
public RoleModule GetRoleModule(int roleId) { string sqlString = string.Empty; sqlString += "SELECT ID, NAME, ISDEFAULT, ISACTIVE FROM [ROLES] WHERE ID = @RoleId; "; sqlString += "select b.ID, b.[Name], b.DESCRIPTION, b.LINKURL, b.PARENTID, b.SORTID, " + "(select Count(MODULE_ID) from ROLEMODULES WHERE ROLE_ID = @RoleId AND MODULE_ID = b.ID) as IsAuth " + "FROM MODULES b WHERE ISDELETED = 0;"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@RoleId", roleId) }; DataSet ds = QuerySet(sqlString, param); //table[0] = Role //table[1] = Module RoleModule roleModule = new RoleModule(); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; RoleRPS rle = new RoleRPS { ID = Convert.ToInt32(dr["ID"]), Name = dr["NAME"].ToString(), IsActive = Convert.ToBoolean(dr["ISACTIVE"]), IsDefault = Convert.ToBoolean(dr["ISDEFAULT"]) }; roleModule.Role = rle; } if (ds.Tables[1].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[1].Rows) { ModuleRPS mod = new ModuleRPS { ID = Convert.ToInt32(dr["id"]), Name = dr["Name"].ToString(), Description = dr["DESCRIPTION"].ToString(), LinkURL = dr["LINKURL"].ToString(), ParentId = Convert.ToInt32(dr["PARENTID"]), SortId = Convert.ToInt32(dr["SORTID"]), IsAuthorized = Convert.ToInt32(dr["IsAuth"]) > 0 ? true : false }; roleModule.Module.Add(mod); } } return(roleModule); }
public List <RoleRPS> GetRoles() { List <RoleRPS> list = new List <RoleRPS>(); string sqlString = "SELECT ID, NAME, ISDEFAULT, ISACTIVE FROM [ROLES]"; DataTable dt = QueryTable(sqlString); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { RoleRPS rle = BindDataRow(dr); list.Add(rle); } } return(list); }
public RoleRPS GetRole(int Id) { string sqlString = "SELECT ID, NAME, ISDEFAULT, ISACTIVE FROM [ROLES] WHERE ID = @RoleId"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@RoleId", Id) }; DataTable dt = QueryTable(sqlString, param); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; RoleRPS rle = BindDataRow(dr); return(rle); } return(null); }
public RoleRPS GetRoleByUsername(string user) { string sqlString = "Select r.[ID],r.ISACTIVE,r.ISDEFAULT, r.[NAME] From ROLES r, USERROLES ur, USERS u " + "Where u.LOGINNAME = @Username and u.ID = ur.[USER_ID] and ur.[ROLE_ID] = r.[ID];"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@Username", user) }; DataTable dt = QueryTable(sqlString, param); if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; RoleRPS rle = BindDataRow(dr); return(rle); } return(null); }
private ActionResult TestJson() { List <RoleRPS> roles = RoleRPS.GetRoles(); return(Json(roles, JsonRequestBehavior.AllowGet)); }
public RoleModule() { Role = new RoleRPS(); Module = new List <ModuleRPS>(); }