public void DismissFromMyWork() { // wait for elastic search to update created entities Thread.Sleep(30000); Run(async() => { var viewModel = new OctaneMyItemsViewModel(); List <BaseEntity> searchedEntities = (List <BaseEntity>) await OctaneServices.GetInstance().SearchEntities(_dismissedStory.Id, 1); if (searchedEntities.Count != 1) { Assert.Fail("Failed to search created story by id"); } await MyWorkUtils.AddToMyWork(searchedEntities[0]); await viewModel.LoadMyItemsAsync(); var searchedMyWorkItem = viewModel.MyItems.ToList().Find(ui => ui.ID.Equals(_dismissedStory.Id)); Assert.IsTrue(searchedMyWorkItem.ID.Equals(_dismissedStory.Id)); await MyWorkUtils.RemoveFromMyWork(searchedMyWorkItem.Entity); await viewModel.LoadMyItemsAsync(); searchedMyWorkItem = viewModel.MyItems.ToList().Find(ui => ui.ID.Equals(_dismissedStory.Id)); Assert.IsTrue(searchedMyWorkItem == null); }).Wait(); }
public static async void RemoveFromMyWork(BaseEntity entity) { if (entity == null) { return; } try { if (entity.TypeName.Equals("comment")) { OctaneServices octaneService = OctaneServices.GetInstance(); await octaneService.RemoveCommentFromMyWork(entity); MessageBox.Show("Dismissed: " + entity.TypeName + " #" + entity.Id, ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Information); } else { await MyWorkUtils.RemoveFromMyWork(entity); MessageBox.Show("Dismissed: " + entity.GetStringValue("name"), ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Information); } await OctaneMyItemsViewModel.Instance.LoadMyItemsAsync(); } catch (Exception ex) { MessageBox.Show("Unable to remove item to my work.\n\n" + "Failed with message: " + ex.Message, ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Error); } }