public void GetForPartner(User user) { VtsWebServiceClient client = new VtsWebServiceClient(); client.GetClientsForPartnerCompleted += delegate(object s, GetClientsForPartnerCompletedEventArgs e) { if (e.Error != null) { errorCallback.Invoke(e.Error, e.Error.Message); } else { IList <User> result = new List <User>(); foreach (UserDto userDto in e.Result) { User gotUser = UserAssembler.Assemble(userDto); result.Add(gotUser); } usersCallback.Invoke(result); } }; client.GetAllUsersCompleted += delegate(object s, GetAllUsersCompletedEventArgs e) { if (e.Error != null) { errorCallback.Invoke(e.Error, e.Error.Message); } else { IList <User> result = new List <User>(); foreach (UserDto userDto in e.Result) { result.Add(UserAssembler.Assemble(userDto)); } usersCallback.Invoke(result); } }; if (user.Role == UserRole.Administrator) { client.GetAllUsersAsync(LoggedUserContext.LoggedUser.Login, LoggedUserContext.LoggedUser.PasswordHash); } else if (user.Role == UserRole.Partner) { client.GetClientsForPartnerAsync(user.Login, user.PasswordHash); client.CloseAsync(); } else { throw new Exception("Client has no access to this code."); } }
public void GetUser(string login, string password) { VtsWebServiceClient service = new VtsWebServiceClient(); service.AuthenticateUserCompleted += delegate(object s, AuthenticateUserCompletedEventArgs e) { if (e.Error != null) { ErrorCallback(e.Error, e.Error.Message); } else { User result = UserAssembler.Assemble(e.Result); GetUserCallback(result); } }; service.AuthenticateUserAsync(login, Sha256Hash.Calculate(password)); }