private string DeletePaperDocs(IPaperModel model, IPaperView view, IMainPresenter presenter) { string errorMessage = string.Empty; string fileAccessToken = ApplicationResource.DefaultAccessToken; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.ArchivePaperDocUrl = ApplicationResource.ActionArchivePaperDocs; service.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = null; IMemberServices servicePerm = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); servicePerm.PermDeletePaperDocUrl = ApplicationResource.ActionPermanentlyDeletePaperDocs; servicePerm.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse responsePerm = null; try { foreach (PaperListViewItemModel item in model.Paper) { if (view.ArchiveSetting && item.IsChecked) { response = service.ArchivePaperDoc(item.MemberId, fileAccessToken, item.PaperId); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Archived Paper doc [" + item.PaperName + "]")); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_DELETE_PAPER; } } if (view.PermanentSetting && item.IsChecked) { responsePerm = servicePerm.PermDeletePaperDoc(item.MemberId, fileAccessToken, item.PaperId); if (responsePerm.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Permanently deleted Paper doc [" + item.PaperName + "]")); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_DELETE_PAPER; } } } } catch (Exception) { // error message. SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.FAILED_TO_DELETE_PAPER, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } return(errorMessage); }