public MainViewModel() { UserConnectedName = "<Desconectado>"; UserConnected = false; LoginCommand = new ComandoSimple(TryLogin, () => Context.Current.Sesion == null); LogoutCommand = new ComandoSimple(Logout, () => Context.Current.Sesion != null); }
public LoginViewModel(Action<ActionRequest> notify) { _notify = notify ?? delegate(ActionRequest r) { }; ComandoIngresar = new ComandoSimple(() => { Debug.WriteLine("Llamar a Login Usuario {0} , Pass: {1}", Login, Password); SecurityServices srv = new SecurityServices(); try { if ((Usuario = srv.Login(Login, Password)) != null) { Perfiles = new ObservableCollection<Perfil>(Usuario.Perfiles); PerfilSeleccionado = Perfiles[0]; _notify(ActionRequest.CloseOK); } } catch (OMBSecurityException ex) { OnLoginError(ex.Message); } }, IsValid); ComandoIngresarPerfil = new ComandoSimple(() => { SecurityServices srv = new SecurityServices(); srv.CrearSesion(Usuario, PerfilSeleccionado); Debug.WriteLine("Perfil Seleccionado: {0}", (object)_perfil.Descripcion); _notify(ActionRequest.CloseOK); }); ComandoCancelar = new ComandoSimple(() => _notify(ActionRequest.CloseCancel)); PerfilSeleccionado = null; }
public TestViewModel() { LoginCommand = new ComandoSimple((x) => { TryLogin(); }, (x) => { return Context.Current.Sesion == null; // return true; }); LogoutCommand = new ComandoSimple( (x) => { // }, (x) => { return Context.Current.Sesion != null; }); }
public ExceptionNotificationViewModel(Action<ActionRequest> notify) { _notify = notify ?? delegate(ActionRequest r) { }; ComandoAceptar = new ComandoSimple(() => _notify(ActionRequest.Close)); }