예제 #1
0
        public void SignOut()
        {
            var uploadPhotoManager = IoC.Get <UploadPhotoManagerViewModel>();

            if (uploadPhotoManager.HasMoreTasks())
            {
                MessageBoxViewModel message = new MessageBoxViewModel();
                message.DisplayName  = AppStrings.SignOutWindowTitle;
                message.Header       = AppStrings.UnfinishedPhotoUploadsMessageHeader;
                message.Message      = AppStrings.UnfinishedPhotoUploadsMessage;
                message.Buttons      = MessageBoxButtons.YesNo;
                message.MessageLevel = MessageLevel.Question;
                message.Closed      += (mSender, mEventArgs) =>
                {
                    if (message.Result == MessageBoxResult.Positive)
                    {
                        uploadPhotoManager.Clear();
                        SecurityContext.Current.SignOut();
                    }
                };
                IoC.Get <IWindowManager>().ShowDialog(message);
            }
            else
            {
                SecurityContext.Current.SignOut();
            }
        }
예제 #2
0
        public static void Handle(this Exception ex)
        {
            var model = new MessageBoxViewModel()
            {
                MessageLevel = MessageLevel.Error, Buttons = MessageBoxButtons.OK, Header = ErrorStrings.GenericErrorMessageHeader
            };

            if (ex is FaultException <ServerFault> )
            {
                FaultException <ServerFault> faultEx = (FaultException <ServerFault>)ex;
                if (faultEx.Detail.FaultCode == ServerFaultCode.Generic)
                {
                    model.Message = ErrorStrings.GenericServerErrorMessage;
                }
                else if (faultEx.Detail.FaultCode == ServerFaultCode.NotAuthroized)
                {
                    model.Message = ErrorStrings.NotAuthorizedServerErrorMessage;
                }
            }
            else
            {
                model.Message = ex.ToString(); //ErrorStrings.UnknownServerErrorMessage;
            }

            Execute.OnUIThread(() => IoC.Get <IWindowManager>().ShowDialog(model));
        }
예제 #3
0
 static void HandleSignUpResult(SignUpStatus status)
 {
     if (status == SignUpStatus.Success)
     {
         Execute.OnUIThread(() =>
         {
             MessageBoxViewModel message = new MessageBoxViewModel();
             message.DisplayName         = AppStrings.SignUpWindowTitle;
             message.Header       = AppStrings.SucceededMessageHeader;
             message.MessageLevel = MessageLevel.Success;
             message.Message      = AppStrings.SignUpSuccessMessage;
             IoC.Get <IWindowManager>().ShowDialog(message);
         });
     }
     else
     {
         var errorMessage = GetSignUpErrorMessage(status);
         Execute.OnUIThread(() =>
         {
             MessageBoxViewModel message = new MessageBoxViewModel();
             message.DisplayName         = AppStrings.SignUpWindowTitle;
             message.Header       = AppStrings.FailedMessageHeader;
             message.MessageLevel = MessageLevel.Exclamation;
             message.Message      = errorMessage;
             IoC.Get <IWindowManager>().ShowDialog(message);
         });
     }
 }
예제 #4
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;
            });
        }
예제 #5
0
        public void DeleteSelectedPhotos()
        {
            if (IsBusy)
            {
                return;
            }
            if (_photos != null && _photos.Any(x => x.IsSelected))
            {
                MessageBoxViewModel message = new MessageBoxViewModel()
                {
                    Buttons      = MessageBoxButtons.YesNo,
                    MessageLevel = MessageLevel.Exclamation,
                    Header       = AppStrings.DeletePhotoMessageHeader,
                    Message      = AppStrings.ConfirmDeletePhotoMessage,
                    DisplayName  = AppStrings.ConfirmationWindowTitle
                };
                message.Closed += (messageSender, messageEventArgs) =>
                {
                    if (message.Result != MessageBoxResult.Positive)
                    {
                        return;
                    }

                    try
                    {
                        IsBusy = true;
                        var parameters = _photos.Where(x => x.IsSelected).Select(x =>
                                                                                 new DeletePhotoParameters()
                        {
                            PhotoId = x.Id, FileName = Path.GetFileName(x.PhotoURI)
                        }).ToList();
                        PhotoServiceClient svc = new PhotoServiceClient();
                        svc.DeletePhotosCompleted += (sender, e) =>
                        {
                            IsBusy = false;
                            if (e.Error != null)
                            {
                                e.Error.Handle();
                            }
                            else
                            {
                                _photos.RefreshCurrentPage();
                                Covers = GetCovers(e.Result);
                            }
                        };
                        svc.DeletePhotosAsync(parameters, Id);
                    }
                    catch
                    {
                        IsBusy = false;
                    }
                };
                IoC.Get <IWindowManager>().ShowDialog(message);
            }
        }
예제 #6
0
        void DeleteAlbum(string id)
        {
            if (IsBusy)
            {
                return;
            }
            MessageBoxViewModel message = new MessageBoxViewModel()
            {
                Buttons      = MessageBoxButtons.YesNo,
                MessageLevel = MessageLevel.Exclamation,
                Header       = AppStrings.DeleteAlbumMessageHeader,
                Message      = AppStrings.ConfirmDeleteAlbumMessage,
                DisplayName  = AppStrings.ConfirmationWindowTitle
            };

            message.Closed += (messageSender, messageEventArgs) =>
            {
                if (message.Result != MessageBoxResult.Positive)
                {
                    return;
                }

                try
                {
                    IsBusy = true;
                    PhotoServiceClient svc = new PhotoServiceClient();
                    svc.DeleteAlbumCompleted += (sender, e) =>
                    {
                        if (e.Error != null)
                        {
                            e.Error.Handle();
                        }
                        else
                        {
                            _albums.RefreshCurrentPage();
                        }
                    };
                    svc.DeleteAlbumAsync(id);
                }
                catch
                {
                    IsBusy = false;
                }
            };
            IoC.Get <IWindowManager>().ShowDialog(message);
        }