Ejemplo n.º 1
0
        public void SignUp()
        {
            RefreshBindingScope.Scope();
            if (this.Validator.HasErrors)
            {
                return;
            }
            try
            {
                IsBusy = true;
                SecurityServiceClient client = new SecurityServiceClient();

                client.SignUpCompleted += (sender, e) =>
                {
                    IsBusy = false;
                    if (e.Error != null)
                    {
                        e.Error.Handle();
                    }
                    else
                    {
                        HandleSignUpResult(e.Result);
                    }
                    if (SignUpCompleted != null)
                    {
                        SignUpCompleted(this, EventArgs.Empty);
                    }
                };
                client.SignUpAsync(UserName, Password, Email);
            }
            catch
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 2
0
        public void Create()
        {
            RefreshBindingScope.Scope();
            if (this.Validator.HasErrors)
            {
                return;
            }

            IsBusy = true;
            try
            {
                PhotoServiceClient svc = new PhotoServiceClient();
                Album album            = new Album();
                album.Name = Name;
                svc.CreateAlbumCompleted += (sender, e) =>
                {
                    IsBusy = false;
                    if (e.Error != null)
                    {
                        e.Error.Handle();
                    }
                    if (CreateCompleted != null)
                    {
                        CreateCompleted(this, new AsyncOperationCompletedEventArgs(e.Error));
                    }
                };
                svc.CreateAlbumAsync(album);
            }
            catch
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 3
0
        public void SignIn()
        {
            RefreshBindingScope.Scope();
            if (this.Validator.HasErrors)
            {
                return;
            }
            IsBusy = true;
            SecurityContext.Current.SignIn(UserName, Password, KeepSignedIn, result =>
            {
                if (!result.Success)
                {
                    var messageBox = new MessageBoxViewModel()
                    {
                        MessageLevel = ViewModels.MessageLevel.Exclamation,
                        Buttons      = MessageBoxButtons.OK,
                        Header       = AppStrings.SignInFailedMessageHeader,
                        Message      = result.Error,
                        DisplayName  = AppStrings.SignInWindowTitle
                    };
                    IoC.Get <IWindowManager>().ShowDialog(messageBox);
                }
                else
                {
                    if (SignInSucceeded != null)
                    {
                        SignInSucceeded(this, EventArgs.Empty);
                    }
                }

                IsBusy = false;
            });
        }
Ejemplo n.º 4
0
 public void Save()
 {
     RefreshBindingScope.Scope();
     if (this.Validator.HasErrors)
     {
         return;
     }
 }
Ejemplo n.º 5
0
 public EditAlbumViewModel(AlbumViewModel target)
 {
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     DisplayName         = AppStrings.EditAlbumWindowTitle;
     RefreshBindingScope = new RefreshBindingScope();
     _target             = target;
     _name        = target.Name;
     _description = target.Description;
 }
Ejemplo n.º 6
0
        public void Save()
        {
            RefreshBindingScope.Scope();
            if (this.Validator.HasErrors)
            {
                return;
            }

            IsBusy = true;
            try
            {
                PhotoServiceClient svc = new PhotoServiceClient();
                svc.UpdateAlbumCompleted += (sender, e) =>
                {
                    IsBusy = false;
                    if (e.Error != null)
                    {
                        e.Error.Handle();
                    }
                    else
                    {
                        _target.Name        = Name;
                        _target.Description = Description;
                        if (EditCompleted != null)
                        {
                            EditCompleted(this, EventArgs.Empty);
                        }
                    }
                };
                svc.UpdateAlbumAsync(Name, Description, _target.Id);
            }
            catch
            {
                IsBusy = false;
            }
        }
Ejemplo n.º 7
0
 public MemoViewModel()
 {
     RefreshBindingScope = new RefreshBindingScope();
 }
Ejemplo n.º 8
0
 public SignUpViewModel()
 {
     DisplayName         = AppStrings.SignUpWindowTitle;
     RefreshBindingScope = new RefreshBindingScope();
 }
Ejemplo n.º 9
0
 public CreateAlbumViewModel()
 {
     DisplayName         = AppStrings.CreateAlbumWindowTitle;
     RefreshBindingScope = new RefreshBindingScope();
 }
Ejemplo n.º 10
0
 public SignInViewModel()
 {
     DisplayName = AppStrings.SignInWindowTitle;
     RefreshBindingScope = new RefreshBindingScope();
 }
Ejemplo n.º 11
0
 public CreateAlbumViewModel()
 {
     DisplayName = AppStrings.CreateAlbumWindowTitle;
     RefreshBindingScope = new RefreshBindingScope();
 }