void PostComment(string contents) { if (IsLoadingComments) { return; } CanPostComment = false; PhotoComment comment = new PhotoComment(); comment.Contents = contents; comment.CreatedBy = SecurityContext.Current.User.Name; comment.PhotoId = Id; comment.AlbumId = AlbumId; PhotoServiceClient svc = new PhotoServiceClient(); try { svc.CreateCommentCompleted += (sender, e) => { if (e.Error != null) { e.Error.Handle(); } else { if (_comments != null) { _comments.Insert(0, MapToPhotoCommentViewModel(e.Result)); } } CanPostComment = true; CommentContents = string.Empty; NotifyOfPropertyChange(() => HasComment); }; svc.CreateCommentAsync(comment); } catch { CanPostComment = true; } }
void PostComment(string contents) { if (IsLoadingComments) return; CanPostComment = false; PhotoComment comment = new PhotoComment(); comment.Contents = contents; comment.CreatedBy = SecurityContext.Current.User.Name; comment.PhotoId = Id; comment.AlbumId = AlbumId; PhotoServiceClient svc = new PhotoServiceClient(); try { svc.CreateCommentCompleted += (sender, e) => { if (e.Error != null) { e.Error.Handle(); } else { if (_comments != null) { _comments.Insert(0, MapToPhotoCommentViewModel(e.Result)); } } CanPostComment = true; CommentContents = string.Empty; NotifyOfPropertyChange(() => HasComment); }; svc.CreateCommentAsync(comment); } catch { CanPostComment = true; } }