private void RetrieveAllConsents()
        {
            string          outputMessage = "";
            List <string[]> tableContent  = ConsentAPI.RetrieveAllConsents(_viewModel.UserID, out outputMessage);

            if (tableContent != null)
            {
                foreach (string[] columns in tableContent)
                {
                    string userID         = columns[0];
                    string permissionID   = columns[1];
                    string createdTime    = columns[2];
                    string expirationTime = columns[3];
                    string legalText      = columns[4];

                    _viewModel.AddConsentToList(
                        Convert.ToInt32(userID),
                        Convert.ToInt32(permissionID),
                        Convert.ToDateTime(createdTime),
                        Convert.ToDateTime(expirationTime),
                        legalText
                        );
                }
            }
        }
Exemplo n.º 2
0
        private void ShowActiveConsents()
        {
            string          outputMessage = "";
            List <string[]> outputList    = ConsentAPI.RetrieveAllConsents(Convert.ToInt32(userID), out outputMessage);

            GUIHandler.PrintTableOrMessage(outputList, outputMessage);
        }
Exemplo n.º 3
0
        private void NewPermissionRequest()
        {
            ShowAllPermissions();

            Console.WriteLine("Choose permission Id");
            string permissionChoice = Console.ReadLine();

            Console.WriteLine("Define duration of permission");
            string duration = Console.ReadLine();


            string outputMessage  = "";
            bool   isConsentGiven = ConsentAPI.CheckForConsent(Convert.ToInt32(this.userID), Convert.ToInt32(permissionChoice), out outputMessage);

            if (outputMessage != "" && !isConsentGiven)
            {
                Console.WriteLine(PermissionAPI.CreatePermissionRequest(this.userID, permissionChoice, duration));

                DateTime dateDuration = new DateTime();
                dateDuration = DateTime.Now;
                dateDuration = dateDuration.AddHours(Convert.ToDouble(duration));
                Console.WriteLine(ConsentAPI.SaveConsent(Convert.ToInt32(this.userID), Convert.ToInt32(permissionChoice), dateDuration));
            }
            else
            {
                Console.WriteLine(outputMessage);
            }
        }
Exemplo n.º 4
0
        private void RevokeConsent()
        {
            ShowActiveConsents();

            Console.WriteLine("Enter permissionID to revoke corresponding consent");
            string permissionID = Console.ReadLine();

            Console.WriteLine(ConsentAPI.RevokeConsent(Convert.ToInt32(userID), Convert.ToInt32(permissionID)));
        }
Exemplo n.º 5
0
        private void RevokeConsent()
        {
            ShowAllPermissions();

            Console.WriteLine("Enter permissionId");
            string permissionID = Console.ReadLine();

            Console.WriteLine(ConsentAPI.RevokeConsent(Convert.ToInt32(this.userID), Convert.ToInt32(permissionID)));
        }
        private void btnSelectPermission_Click(object sender, RoutedEventArgs e)
        {
            DateTime expirationTime = new DateTime();

            expirationTime = DateTime.Now;
            expirationTime = expirationTime.AddHours(Convert.ToDouble(_viewModel.PermissionDuration));
            ConsentAPI.SaveConsent(_viewModel.UserID, _viewModel.SelectedPermission.PermissionID, expirationTime);
            _viewModel.ClearPermissionList();
            this.Close();
        }
 private void btnRemoveConsent_Click(object sender, RoutedEventArgs e)
 {
     ConsentAPI.RevokeConsent(_viewModel.SelectedConsent.UserID, _viewModel.SelectedConsent.PermissionID);
     _viewModel.ClearConsentList();
     this.Close();
 }