Example #1
0
 private void B_Save_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         // Checking null values
         if (!string.IsNullOrEmpty(T_Username.Text) || !string.IsNullOrEmpty(T_Role.Text))
         {
             // Saving
             APICall.AddUserToTeam("UrbanCoder", T_Username.Text, T_Role.Text);
             output = true;
             Close();
         }
     }
     catch (UC_UnknownUser ex)
     {
         output              = false;
         TB_Error.Text       = ex.Message;
         TB_Error.Visibility = Visibility.Visible;
     }
     catch (Exception ex)
     {
         output              = false;
         TB_Error.Text       = ex.Message;
         TB_Error.Visibility = Visibility.Visible;
     }
 }
Example #2
0
 private void Login()
 {
     try
     {
         ShowErrorMessage();
         // Validating Login Prerequisites
         if (string.IsNullOrEmpty(T_URI.Text) || string.IsNullOrEmpty(T_Username.Text) || string.IsNullOrEmpty(T_Password.Password))
         {
             ShowErrorMessage("Enter the URL, Username and Password !");
             return;
         }
         // Creating API Client
         APICall = new UCD_Client(T_URI.Text, T_Username.Text, T_Password.Password, CB_Cert.IsChecked.Value);
         // Fetching UrbanCoder team information
         teamInfo = APICall.GetTeamInfo("UrbanCoder");
         // Checking if user is part of UrbanCoder team
         bool addToTeam = true;
         foreach (UCD_Data.TeamInfo.RoleMapping userData in teamInfo.APIData.roleMappings)
         {
             if (userData.user.name == T_Username.Text)
             {
                 addToTeam = false;
                 break;
             }
         }
         // Adding user to Team
         if (addToTeam)
         {
             APICall.AddUserToTeam("UrbanCoder", T_Username.Text, "Administrator");
         }
         // Successfully Logged In
         IsLoggedIn(true);
         ShowErrorMessage();
         FillUsers();
         // Checking if UrbanCoder pre-requisites are met.(Resource data etc)
         resourceInfo = APICall.ListResources("UrbanCoder");
     }
     catch (UC_LoginFailed)
     {
         ShowErrorMessage("Invalid Username or Password !");
     }
     catch (UC_TeamNotFound)
     {
         // First Login detected, trying to create a Team
         CreateTeam();
     }
     catch (UC_UnknownUser)
     {
         ShowErrorMessage("You do not belong to the UrbanCoder Team in UCD !");
     }
     catch (UC_ResourceNotFound)
     {
         // Enabling create data options as the resource is not there.
         SP_CreateDataHolder.IsEnabled = true;
         CreateParentResource();
     }
     catch (Exception ex)
     {
         ShowErrorMessage("Error in Login: " + ex.Message);
     }
 }