Exemplo n.º 1
0
        public static string FindRightIdFor(ProductType product, UserClaimAbility userClaimAbility)
        {
            // Connect to sql
            SqlConnection myConnection = SQLDatabaseConnection.ConnectTo("QA-AZUKS-DMI2", "CTN_Report");

            myConnection.Open();

            //string id = "";
            string select         = "SELECT [CTN_Report].[dbo].[Right].[RightId] ";
            string from           = "FROM [CTN_Report].[dbo].[Module] ";
            string innerJoin      = "INNER JOIN[CTN_Report].[dbo].[Right] ON [CTN_Report].[dbo].[Module].[ModuleId] = [CTN_Report].[dbo].[Right].[ModuleId] ";
            string whereProductIs = $"WHERE[CTN_Report].[dbo].[Module].[Name] = '{product.ToString()}' ";
            string whereAbilityIs = $"AND [CTN_Report].[dbo].[Right].[Name] = '{userClaimAbility.ToString()}'";

            string command = select + from + innerJoin + whereProductIs + whereAbilityIs;

            SqlCommand myCommand = new SqlCommand(command, myConnection);

            return(SQLRead.FromDatabase(command, "RightId", myConnection));
        }