/// <summary> /// Controlses the visibility. /// </summary> private void ControlsVisibility() { WellKnownUserType selUserType = (WellKnownUserType)App.BaseUserControl.UserModel.UserType; switch (selUserType) { case WellKnownUserType.GuestUser: case WellKnownUserType.Student: DarkArchieveAndButtonVisibility(Visibility.Collapsed, Visibility.Collapsed); DeleteButtonVisibility(Visibility.Collapsed); break; case WellKnownUserType.Staff: DarkArchieveAndButtonVisibility(Visibility.Collapsed, Visibility.Visible); DeleteButtonVisibility(Visibility.Collapsed); break; case WellKnownUserType.AdminUser: DarkArchieveAndButtonVisibility(Visibility.Visible, Visibility.Visible); DeleteButtonVisibility(Visibility.Visible); break; default: break; } }
/// <summary> /// Views the user. /// </summary> private void ViewUser() { RequestModel requestModel = new RequestModel() { UserModel = new UserModel() { UserId = UserId }, }; ResponseModel response = App.BaseUserControl.InternalService.GetUser(requestModel); if (response.IsOperationSuccess) { UserModel user = response.UserModel; WellKnownUserType userType = (WellKnownUserType)user.UserType; UserTypeComboBox.SelectedIndex = user.UserType - 2; NameTextBox.Text = user.Name; UsernameTextBox.Text = user.Username; } else { App.ShowMessage(false, response.ErrorMessage); } }
/// <summary> /// Controlses the visibility. /// </summary> private void ControlsVisibility() { WellKnownUserType selUserType = (WellKnownUserType)App.BaseUserControl.UserModel.UserType; switch (selUserType) { case WellKnownUserType.GuestUser: case WellKnownUserType.Student: case WellKnownUserType.Staff: RestrictionsBorder1.Visibility = Visibility.Collapsed; RestrictionsLabel.Visibility = Visibility.Collapsed; RestrictionsStackPanel.Visibility = Visibility.Collapsed; RestrictionsBorder2.Visibility = Visibility.Collapsed; RestrictionNoteTextBox.Visibility = Visibility.Collapsed; RestrictionNoteLabel.Visibility = Visibility.Collapsed; break; case WellKnownUserType.AdminUser: RestrictionsBorder1.Visibility = Visibility.Visible; RestrictionsLabel.Visibility = Visibility.Visible; RestrictionsStackPanel.Visibility = Visibility.Visible; RestrictionsBorder2.Visibility = Visibility.Visible; RestrictionNoteTextBox.Visibility = Visibility.Visible; RestrictionNoteLabel.Visibility = Visibility.Visible; break; default: break; } }
/// <summary> /// Initializes a new instance of the <see cref="AuthorizationModel" /> class. /// </summary> /// <param name="isValidToProcess">if set to <c>true</c> [is valid to process].</param> /// <exception cref="ArgumentNullException">snackbarMessageQueue</exception> public AuthorizationModel(bool isValidToProcess) { if (isValidToProcess) { if (App.BaseUserControl.UserModel != null) { UserName = App.BaseUserControl.UserModel.Name; // user type based menu selection WellKnownUserType userType = (WellKnownUserType)App.BaseUserControl.UserModel.UserType; Usertype = "(" + EnumHelper.StringValueOf((WellKnownUserType)userType) + ")"; switch (userType) { case WellKnownUserType.GuestUser: DemoItems = GuestUserDemoItems; break; case WellKnownUserType.Student: DemoItems = StudentDemoItems; break; case WellKnownUserType.Staff: DemoItems = StaffDemoItems; break; case WellKnownUserType.AdminUser: DemoItems = AdminDemoItems; break; default: break; } } else { DemoItems = GuestUserDemoItems; } } else { DemoItems = HomeDemoItems; } }
/// <summary> /// Handles the Click event of the SaveUserDetails control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void SaveUserDetails_Click(object sender, RoutedEventArgs e) { if (FormValidation()) { ComboBoxItem ComboItem = (ComboBoxItem)UserTypeComboBox.SelectedItem; WellKnownUserType userType = (WellKnownUserType)Enum.Parse(typeof(WellKnownUserType), ComboItem.Name); if (IsAddNewRecord) { RequestModel requestModel = new RequestModel() { UserModel = new UserModel() { UserId = UserId, Name = NameTextBox.Text, Username = UsernameTextBox.Text, UserType = (byte)userType, Password = PasswordTextBox.SecurePassword, }, WellKnownModificationType = Core.Enums.WellKnownModificationType.Add, }; ResponseModel response = App.BaseUserControl.InternalService.ModifyUser(requestModel); if (response.IsOperationSuccess) { App.ShowMessage(true, string.Empty); } else { App.ShowMessage(false, response.ErrorMessage); } } else { RequestModel requestModel = new RequestModel() { UserModel = new UserModel() { UserId = UserId, Name = NameTextBox.Text, Username = UsernameTextBox.Text, UserType = (byte)userType, }, WellKnownModificationType = Core.Enums.WellKnownModificationType.Edit, }; ResponseModel response = App.BaseUserControl.InternalService.ModifyUser(requestModel); if (response.IsOperationSuccess) { App.ShowMessage(true, string.Empty); } else { App.ShowMessage(false, response.ErrorMessage); } } } else { App.ShowMessage(false, "Fill all the fields."); } }