コード例 #1
0
 private void buttonSignIn_Click(object sender, EventArgs e)
 {
     try
     {
         AuthenticationServiceClient client = new AuthenticationServiceClient();
         OperationResult <User>      result = client.AuthorizationUser(textBoxLogin.Text, textBoxPassword.Text);
         if (result.Success)
         {
             Hide();
             if (result.Result.Roles.First <Role>().RoleName.Equals("Admin"))
             {
                 AdminForm adminForm = new AdminForm(result.Result);
                 adminForm.FormClosed += FormClosed;
                 adminForm.Show();
             }
             else
             {
                 OtherUserForm otherUserForm = new OtherUserForm(result.Result);
                 otherUserForm.FormClosed += FormClosed;
                 otherUserForm.Show();
             }
         }
         else
         {
             MessageBox.Show("Invalid login or password!");
         }
     }
     catch (FaultException exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
コード例 #2
0
 public Entities.User TryAuthentication(string login, string password)
 {
     using (var client = new AuthenticationServiceClient())
     {
         OperationResultOfUser result = client.AuthorizationUser(login, password);
         return(ServiceMapper.Mapper.Map <Entities.User>(result.Result));
     }
 }