Exemple #1
0
 private async Task FillAccountRoleBox()
 {
     if (LoginBox.Text.Length > 0)
     {
         if (await CheckAccountExistsAsync())
         {
             AccountRoleBox.ClearValue(ItemsControl.ItemsSourceProperty);
             AccountRoleBox.DisplayMemberPath = "Name";
             AccountRoleBox.SelectedValuePath = "RoleId";
             AccountRoleBox.ItemsSource       = await authCore.GetRolesForOtherAccountAsync(LoginBox.Text);
         }
         else
         {
             MessageBox.Show("Account doesn't exists");
         }
     }
     else
     {
         MessageBox.Show("Login is empty");
     }
 }
Exemple #2
0
        private async Task <bool> CheckChairman()
        {
            if (ChairmanBox.Text.Length > 0 && BeginDatePicker.SelectedDate.HasValue &&
                EndDatePicker.SelectedDate.HasValue &&
                BeginDatePicker.SelectedDate.Value >= UserCredentials.Conference.BeginDate &&
                BeginDatePicker.SelectedDate.Value <= UserCredentials.Conference.EndDate &&
                EndDatePicker.SelectedDate.Value >= UserCredentials.Conference.BeginDate &&
                EndDatePicker.SelectedDate.Value <= UserCredentials.Conference.EndDate)
            {
                var account = await authCore.GetAccountByLoginAsync(ChairmanBox.Text);

                if (account != null)
                {
                    var roles = await authCore.GetRolesForOtherAccountAsync(account.Login);

                    if (roles != null && roles.Exists(role => role.Name.Equals(Properties.RoleResources.SessionChair)))
                    {
                        var response = await core.CheckOverlappingSessionForChairmanAsync(account.AccountId, BeginDatePicker.SelectedDate.Value,
                                                                                          EndDatePicker.SelectedDate.Value, currentSession != null?currentSession.SessionId : 0, currentSpecialSession != null
                                                                                          ?currentSpecialSession.SpecialSessionId : 0);

                        if (response != null && !response.Status)
                        {
                            StatusChairman.Foreground = Brushes.Green;
                            StatusChairman.Kind       = MahApps.Metro.IconPacks.PackIconFontAwesomeKind.CheckSolid;
                            return(true);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Given login is not a session chair or an error occured while checking the roles");
                    }
                }
            }
            StatusChairman.Foreground = Brushes.Red;
            StatusChairman.Kind       = MahApps.Metro.IconPacks.PackIconFontAwesomeKind.TimesCircleSolid;
            return(false);
        }