示例#1
0
        public Task <ReturnRole> ReturnRole(string username)
        {
            try
            {
                ReturnRole role = new ReturnRole();
                using (var conn = _settings.GetConnection())
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }

                    string query = $"SELECT * FROM RETORNA_ROL_ADMINISTRADOR(N'{username}');";
                    using (var cmd = new SqlCommand(query, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        var dr = cmd.ExecuteReader();
                        while (dr.Read())
                        {
                            role.Username        = (string)dr[0];
                            role.IsAdministrator = dr.GetBoolean(1);
                            role.IsSecurity      = dr.GetBoolean(2);
                            role.IsMaintenance   = dr.GetBoolean(3);
                            role.IsAudit         = dr.GetBoolean(4);
                        }
                    }
                }
                return(Task.FromResult(role));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
示例#2
0
 public static void SetLogin(ReturnRole userRoles)
 {
     _userRole = new UserRole()
     {
         Username      = userRoles.Username, IsAdministrator = userRoles.IsAdministrator, IsAudit = userRoles.IsAudit,
         IsMaintenance = userRoles.IsMaintenance, IsSecurity = userRoles.IsSecurity
     };
 }
示例#3
0
        public ActionResult RoleUserEdit(string user, ReturnRole data)
        {
            var userStatus = _returnMethods.ReturnRole(data.Username).Result;
            var result     = _updateMethods.UpdateUserRole(new UserRole()
            {
                Username      = user, IsAdministrator = data.IsAdministrator, IsAudit = data.IsAudit,
                IsMaintenance = data.IsMaintenance, IsSecurity = data.IsSecurity
            }).Result;

            if (!result)
            {
                ModelState.AddModelError("", "¡Error al guardar los datos!\n");
                return(RedirectToAction("RoleUserList"));
            }
            return(RedirectToAction("RoleUserList"));
        }