public static AuthenticationResponse Authenticate(string login, string password) { SkypeDataClassesDataContext sdc = new SkypeDataClassesDataContext(); ISingleResult<SP_AuthenticateResult> authenticationResult = sdc.SP_Authenticate(login, password); AuthenticationResponse ar = new AuthenticationResponse(); int returnedValue = (int)authenticationResult.ReturnValue; if (returnedValue == 1) { NetworkPackets.Model.User profile = null; foreach (SP_AuthenticateResult user in authenticationResult) profile = new NetworkPackets.Model.User { Id = user.UserID, Login = user.Login, Email = user.Email, ImageBytes = (user.ImageName == null? null: GetImgByteArrByName(user.ImageName)) }; ar.Profile = profile; ar.ContactList = GetContactListByUserID(profile.Id); } else { ar.HasError = true; if (returnedValue == 0) ar.LoginError = "Doesn't exist!"; if (returnedValue == -1) ar.PasswordError = "Invalid password!"; } return ar; }
public void ProcessAuthenticationResponse(AuthenticationResponse ar) { if (ar.HasError == true) { LoginErrorMessage = ar.LoginError; PasswordErrorMessage = ar.PasswordError; } else { MainWinViewModel.CurrentViewModel.LoadProfile(ar.Profile); MainWinViewModel.CurrentViewModel.LoadContacts(ar.ContactList); ar.UnreceivedMessages.ForEach((i) => { MainWinViewModel.CurrentViewModel.ProcessIncomingMessage(i); }); _closeWindow(AuthenticationDialogResult.Authenticated); } }