Example #1
0
        public IActionResult GrantRoleRole(string id)
        {
            using (var ole = new OracleConnection(config.GetConnectionString("DefaultConnection")))
            {
                GrantRoleToRoleViewModel vmGrantRoleToRole = new GrantRoleToRoleViewModel();

                vmGrantRoleToRole.Role = id;

                var roleList = ole.Query <RoleListModel>("SELECT ROLE FROM DBA_ROLES");
                vmGrantRoleToRole.Roles = roleList.Select(x =>
                                                          new SelectListItem()
                {
                    Text  = x.ROLE.ToString(),
                    Value = x.ROLE.ToString()
                });



                return(View(vmGrantRoleToRole));
            }
        }
Example #2
0
        public IActionResult GrantRoleRole(GrantRoleToRoleViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (var conn = new OracleConnection(config.GetConnectionString("DefaultConnection")))
                    {
                        conn.Open();
                        OracleCommand cmd = conn.CreateCommand();
                        cmd.CommandText = $"GRANT {model.Role} TO {model.GrantedRole} ";
                        cmd.ExecuteNonQuery();

                        return(RedirectToAction("ListRoleRolePrivs", "Role"));
                    }
                }
                catch (Exception e)
                {
                }
            }

            return(RedirectToAction(nameof(RoleController.ListRoleRolePrivs), "Role"));
        }