private async void RemoveImage(object o) { var selectedItem = o as INavigatorListEntry; if (!selectedItem.DbId.HasValue) { return; } var mySettings = new MetroDialogSettings { AffirmativeButtonText = "Yes", NegativeButtonText = "No", ColorScheme = MetroDialogColorScheme.Accented }; var result = await _view.ShowMessageDialog("Remove Element", $"Are you sure you want to remove this element from database?", MessageDialogStyle.AffirmativeAndNegative, mySettings); if (result == MessageDialogResult.Affirmative) { await Task.Run(() => { ImoutoService.Use(imoutoService => { imoutoService.RemoveImage(selectedItem.DbId.Value); }); }); // NavigatorList.Remove(selectedItem); await _view.ShowMessageDialog("Remove Element", "Element successfully removed.", MessageDialogStyle.Affirmative, new MetroDialogSettings { ColorScheme = MetroDialogColorScheme.Accented }); } }
public async void UpdateCurrentTags(INavigatorListEntry listEntry) { if (listEntry?.DbId == null) { IsRateSetted = false; return; } var id = listEntry.DbId.Value; var tags = await Task.Run(() => { return(ImoutoService.Use(imoutoService => { return imoutoService.GetImageTags(id); })); }); _lastListEntryId = id; var tagVmsCollection = tags.Where(x => x.Tag.Type.Title != "LocalMeta") .Select(x => new BindedTagVM(x, listEntry.DbId)) .ToList(); CurrentTagsSources.Clear(); var userTags = tagVmsCollection.Where(x => x.Model.Source == Source.User) .ToList(); if (userTags.Any()) { CurrentTagsSources.Add(new TagSourceVM { Title = "User", Tags = new ObservableCollection <BindedTagVM>(userTags) }); } var parsedSources = tagVmsCollection.Select(x => x.Model.Source) .Where(x => x != Source.User) .Distinct(); foreach (var parsedSource in parsedSources) { CurrentTagsSources.Add(new TagSourceVM { Title = parsedSource.ToString(), Tags = new ObservableCollection <BindedTagVM>(tagVmsCollection.Where(x => x.Model.Source == parsedSource) .OrderBy(x => x.TypePriority) .ThenBy(x => x.Tag.Title)) }); } GetFavorite(tags); GetRate(tags); IsRateSetted = true; }
private Task UnbindTagTask(int imageId, int tagId) { return Task.Run(() => { ImoutoService.Use(imoutoService => { imoutoService.UnbindTag(imageId, tagId); }); }); }
private Task <List <TagType> > ReloadTagTypesTask() { return(Task.Run(() => { return ImoutoService.Use(imoutoService => { return imoutoService.GetTagTypes(); }); })); }
private static Task <List <Tag> > SearchTagsAsyncTask(string searchString) { return(Task.Run(() => { return ImoutoService.Use(imoutoService => { return imoutoService.SearchTags(searchString); }); })); }
private Task <int> GetImagesCountFromCollectionAsyncTask() { return(Task.Run(() => { return ImoutoService.Use(imoutoService => { return imoutoService.CountSearchImage(TagSearchVM.SelectedColleciton.Value, TagSearchVM.SelectedBindedTags.Select(x => x.Model).ToList()); }); })); }
private Task <List <Tag> > LoadTagsTask(string searchPattern) { return(Task.Run(() => { var tags = ImoutoService.Use(imoutoService => { return imoutoService.SearchTags(searchPattern); }); return tags; })); }
private Task CreateTagTask(CreateTagVM createTagVM) { return(Task.Run(() => { ImoutoService.Use(imoutoService => { imoutoService.CreateTag(new Tag { HasValue = createTagVM.HasValue, SynonymsCollection = createTagVM.SynonymsCollection, Title = createTagVM.Title, Type = createTagVM.SelectedType }); }); })); }
private Task <ObservableCollection <INavigatorListEntry> > GetImagesFromCollectionAsyncTask(int count, int skip) { return(Task.Run(() => { return new ObservableCollection <INavigatorListEntry>(ImoutoService.Use(imoutoService => { return imoutoService.SearchImage(TagSearchVM.SelectedColleciton.Value, TagSearchVM .SelectedBindedTags .Select(x => x.Model) .ToList(), count, skip, App.AppGuid); }).Select(x => EntryVM.GetListEntry(x.Item1, PreviewSize, x.Item2)) .SkipExceptions() ); })); }
private async void Save(object obj) { var images = SelectedItems; var tags = SelectedTags; try { IsSavind = true; IsSuccess = false; await Task.Run(() => { ImoutoService.Use(imoutoService => { imoutoService.BatchBindTag(images.Where(x => x.DbId.HasValue) .Select(x => x.DbId.Value) .ToList(), tags.Select(x => new BindedTag { Tag = x.Tag, DateAdded = DateTime.Now, Source = Source.User, Value = (x.Tag.HasValue) ? x.Value : null }) .ToList()); }); }); IsSavind = false; UpdateRecentlyTags(SelectedTags); IsSuccess = true; await Task.Delay(500); IsSuccess = false; } catch { IsSavind = false; } }