/// <summary>
        /// Adds a photo from the specified path to use as a profile photo.
        /// </summary>
        /// <param name="ms">The file stream.</param>
        /// <param name="saveLocalCopy">Set to <c>true</c> to save a local copy, <c>false</c> otherwise.</param>
        /// <param name="showAlert">Set to <c>true</c> to show an alert if photo is too large; <c>false</c> otherwise.</param>
        /// <returns></returns>
        protected internal async Task AddPhoto(MemoryStream ms, bool saveLocalCopy, bool showAlert)
        {
            byte[] bytes = ms.ToArray();
            ms.Dispose();
            if (bytes.Length > this.TagProfile.HttpFileUploadMaxSize.GetValueOrDefault())
            {
                if (showAlert)
                {
                    await this.UiDispatcher.DisplayAlert(AppResources.ErrorTitle, AppResources.PhotoIsTooLarge);
                }
                return;
            }

            RemovePhoto(saveLocalCopy);

            if (saveLocalCopy)
            {
                try
                {
                    File.WriteAllBytes(localPhotoFileName, bytes);
                }
                catch (Exception e)
                {
                    this.LogService.LogException(e);
                }
            }
            this.photo = new LegalIdentityAttachment(localPhotoFileName, Constants.MimeTypes.Jpeg, bytes);
            Image      = ImageSource.FromStream(() => new MemoryStream(bytes));
            RegisterCommand.ChangeCanExecute();
        }
 private void RemovePhoto(bool removeFileOnDisc)
 {
     try
     {
         this.photo = null;
         Image      = null;
         if (removeFileOnDisc && File.Exists(this.localPhotoFileName))
         {
             File.Delete(this.localPhotoFileName);
         }
     }
     catch (Exception e)
     {
         this.LogService.LogException(e);
     }
 }