Beispiel #1
0
 /// <summary>
 /// Staffs the photo uploaded event handler.
 /// </summary>
 /// <param name="staffPhotoUploadedEventArgs">The <see cref="Rem.Ria.AgencyModule.StaffEditor.StaffPhotoUploadedEventArgs"/> instance containing the event data.</param>
 public void StaffPhotoUploadedEventHandler(
     StaffPhotoUploadedEventArgs staffPhotoUploadedEventArgs)
 {
     if (EditingDto.StaffPhoto == null)
     {
         EditingDto.StaffPhoto = new StaffPhotoDto();
     }
     EditingDto.StaffPhoto.Picture = staffPhotoUploadedEventArgs.Picture;
     EditingDto.StaffPhoto.Key     = _staffKey;
     IsEditMode = false;
 }
Beispiel #2
0
        private void ExecuteUploadPhotoCommand(object obj)
        {
            if (SelectedFiles.Count() == 0)
            {
                _userDialogService.ShowDialog("There are no files to upload. Please select a file.", "File Upload", UserDialogServiceOptions.Ok);
            }

            IsLoading = true;

            foreach (var selectedFile in SelectedFiles)
            {
                if (selectedFile.Length > MaxFileSize)
                {
                    _userDialogService.ShowDialog("The file greater than 4MB cannot be uploaded.", "File Upload", UserDialogServiceOptions.Ok);
                }
                else
                {
                    try
                    {
                        Stream stream = selectedFile.OpenRead();
                        var    buffer = ImageHelper.GetCompressedImage(stream, 250, 250);
                        stream.Dispose();
                        stream.Close();

                        var staffPhotoUploadedEvent = new StaffPhotoUploadedEventArgs
                        {
                            Picture = buffer
                        };

                        _eventAggregator.GetEvent <StaffPhotoUploadedEvent> ().Publish(staffPhotoUploadedEvent);
                        RaiseViewClosing();
                    }
                    catch (IOException e)
                    {
                        IsLoading = false;
                        _userDialogService.ShowDialog(e.Message, "Upload File", UserDialogServiceOptions.Ok);
                    }
                }
            }

            IsLoading = false;
        }
        private void ExecuteUploadPhotoCommand( object obj )
        {
            if ( SelectedFiles.Count () == 0 )
            {
                _userDialogService.ShowDialog ( "There are no files to upload. Please select a file.", "File Upload", UserDialogServiceOptions.Ok );
            }

            IsLoading = true;

            foreach ( var selectedFile in SelectedFiles )
            {
                if ( selectedFile.Length > MaxFileSize )
                {
                    _userDialogService.ShowDialog ( "The file greater than 4MB cannot be uploaded.", "File Upload", UserDialogServiceOptions.Ok );
                }
                else
                {
                    try
                    {
                        Stream stream = selectedFile.OpenRead ();
                        var buffer = ImageHelper.GetCompressedImage ( stream, 250, 250 );
                        stream.Dispose ();
                        stream.Close ();

                        var staffPhotoUploadedEvent = new StaffPhotoUploadedEventArgs
                            {
                                Picture = buffer
                            };

                        _eventAggregator.GetEvent<StaffPhotoUploadedEvent> ().Publish ( staffPhotoUploadedEvent );
                        RaiseViewClosing ();
                    }
                    catch ( IOException e )
                    {
                        IsLoading = false;
                        _userDialogService.ShowDialog ( e.Message, "Upload File", UserDialogServiceOptions.Ok );
                    }
                }
            }

            IsLoading = false;
        }