/// <summary> /// This is only ever required after pulling values out of the AtomFeed XML, and is done automatically. /// </summary> private void SyncToModel() { // Model.ProductCode = Id; Model.PackageDetails.SummaryDescription = Summary.Text; Model.PackageDetails.PublishDate = PublishDate.DateTime; var pub = Authors.FirstOrDefault(); if (pub != null) { Model.PackageDetails.Publisher = new Identity { Name = pub.Name, Location = pub.Uri != null?pub.Uri.ToUri() : null, Email = pub.Email }; } Model.PackageDetails.Contributors = Contributors.Select(each => new Identity { Name = each.Name, Location = each.Uri.ToUri(), Email = each.Email, }).ToXList(); Model.PackageDetails.Tags = Categories.Where(each => each.Scheme == "/Tags").Select(each => each.Name).ToXList(); Model.PackageDetails.Categories = Categories.Where(each => each.Scheme == "/Categories").Select(each => each.Name).ToXList(); var content = (Content as TextSyndicationContent); Model.PackageDetails.Description = content == null ? string.Empty : content.Text; Model.PackageDetails.CopyrightStatement = Copyright == null ? string.Empty : Copyright.Text; Model.Locations = Links.Select(each => each.Uri.AbsoluteUri.ToUri()).Distinct().ToXList(); }
public void AddNewAuthor(ActionExecutionContext context, string authorName) { if ((context.EventArgs as KeyEventArgs).Key == Key.Return && !String.IsNullOrWhiteSpace(authorName)) { (context.EventArgs as KeyEventArgs).Handled = true; Author author = Authors.FirstOrDefault(p => p.Name.ToLower() == authorName.ToLower()); if (author != null) { SelectedAuthor = author; return; } if (MessageBox.Show(String.Format(App.GetString("AreYouSureAddAuthor"), authorName), App.GetString("NewAuthor"), MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes) { using (var dbService = _dbServiceManager.GetService()) { Author newAuthor = new Author() { Name = authorName }; newAuthor.Id = dbService.Authors.Add(newAuthor); Authors.Add(newAuthor); SelectedAuthor = newAuthor; } } else { SelectedAuthor = null; } } }
public override void Initialize([AllowNull] ViewWithData data) { base.Initialize(data); IsLoaded = false; PullRequests = repositoryHost.ModelService.GetPullRequests(repository, pullRequests); pullRequests.Subscribe(pr => { trackingAssignees.AddItem(pr.Assignee); trackingAuthors.AddItem(pr.Author); }, () => { }); pullRequests.OriginalCompleted .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => { if (listSettings.SelectedAuthor != null) { SelectedAuthor = Authors.FirstOrDefault(x => x.Login == listSettings.SelectedAuthor); } if (listSettings.SelectedAssignee != null) { SelectedAssignee = Assignees.FirstOrDefault(x => x.Login == listSettings.SelectedAssignee); } IsLoaded = true; UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor); }); }
async Task Load() { IsBusy = true; if (modelService == null) { modelService = await modelServiceFactory.CreateAsync(connection); } if (remoteRepository == null) { remoteRepository = await modelService.GetRepository( localRepository.Owner, localRepository.Name); Repositories = remoteRepository.IsFork ? new[] { remoteRepository.Parent, remoteRepository } : new[] { remoteRepository }; SelectedRepository = Repositories[0]; } PullRequests = modelService.GetPullRequests(SelectedRepository, pullRequests); pullRequests.Subscribe(pr => { trackingAssignees.AddItem(pr.Assignee); trackingAuthors.AddItem(pr.Author); }, () => { }); pullRequests.OriginalCompleted .ObserveOn(RxApp.MainThreadScheduler) ////.Catch<System.Reactive.Unit, Octokit.AuthorizationException>(ex => ////{ //// log.Info("Received AuthorizationException reading pull requests", ex); //// return repositoryHost.LogOut(); ////}) .Catch <System.Reactive.Unit, Exception>(ex => { // Occurs on network error, when the repository was deleted on GitHub etc. log.Error(ex, "Received Exception reading pull requests"); return(Observable.Empty <System.Reactive.Unit>()); }) .Subscribe(_ => { if (listSettings.SelectedAuthor != null) { SelectedAuthor = Authors.FirstOrDefault(x => x.Login == listSettings.SelectedAuthor); } if (listSettings.SelectedAssignee != null) { SelectedAssignee = Assignees.FirstOrDefault(x => x.Login == listSettings.SelectedAssignee); } IsBusy = false; UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor, SearchQuery); }); }
private List <Author> GetMostCommonAuthors(List <Book> books) { List <Author> authors = new List <Author>(); foreach (Book book in books) { authors = authors.Concat(db.BookAuthors.Include("Author") .Where(ba => ba.BookId == book.Id) .Select(ba => ba.Author)) .ToList(); } return(authors.GroupBy(a => a.Id, (id, Authors) => new { Key = id, Count = Authors.Count(), Value = Authors.FirstOrDefault() }).Select(g => g.Value).ToList()); }
public override void Initialize([AllowNull] ViewWithData data) { base.Initialize(data); IsLoaded = false; PullRequests = repositoryHost.ModelService.GetPullRequests(repository, pullRequests); pullRequests.Subscribe(pr => { trackingAssignees.AddItem(pr.Assignee); trackingAuthors.AddItem(pr.Author); }, () => { }); pullRequests.OriginalCompleted .ObserveOn(RxApp.MainThreadScheduler) .Catch <System.Reactive.Unit, Octokit.AuthorizationException>(ex => { log.Info("Received AuthorizationException reading pull requests", ex); return(repositoryHost.LogOut()); }) .Catch <System.Reactive.Unit, Exception>(ex => { // Occurs on network error, when the repository was deleted on GitHub etc. log.Info("Received Exception reading pull requests", ex); return(Observable.Empty <System.Reactive.Unit>()); }) .Subscribe(_ => { if (listSettings.SelectedAuthor != null) { SelectedAuthor = Authors.FirstOrDefault(x => x.Login == listSettings.SelectedAuthor); } if (listSettings.SelectedAssignee != null) { SelectedAssignee = Assignees.FirstOrDefault(x => x.Login == listSettings.SelectedAssignee); } IsLoaded = true; UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor); }); }
public override void Initialize([AllowNull] ViewWithData data) { base.Initialize(data); IsLoaded = false; PullRequests = repositoryHost.ModelService.GetPullRequests(repository, pullRequests); pullRequests.Subscribe(pr => { trackingAssignees.AddItem(pr.Assignee); trackingAuthors.AddItem(pr.Author); }, () => { }); pullRequests.OriginalCompleted .ObserveOn(RxApp.MainThreadScheduler) .Catch <System.Reactive.Unit, Octokit.AuthorizationException>(ex => { // TODO: Do some decent logging here return(repositoryHost.LogOut()); }) .Catch <System.Reactive.Unit, Octokit.NotFoundException>(ex => { //this is caused when repository was deleted on github return(Observable.Empty <System.Reactive.Unit>()); }) .Subscribe(_ => { if (listSettings.SelectedAuthor != null) { SelectedAuthor = Authors.FirstOrDefault(x => x.Login == listSettings.SelectedAuthor); } if (listSettings.SelectedAssignee != null) { SelectedAssignee = Assignees.FirstOrDefault(x => x.Login == listSettings.SelectedAssignee); } IsLoaded = true; UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor); }); }
Task Load() { IsBusy = true; PullRequests = modelService.GetPullRequests(SelectedRepository, pullRequests); pullRequests.Subscribe(pr => { trackingAssignees.AddItem(pr.Assignee); trackingAuthors.AddItem(pr.Author); }, () => { }); pullRequests.OriginalCompleted .ObserveOn(RxApp.MainThreadScheduler) .Catch <System.Reactive.Unit, Exception>(ex => { // Occurs on network error, when the repository was deleted on GitHub etc. log.Error(ex, "Received Exception reading pull requests"); return(Observable.Empty <System.Reactive.Unit>()); }) .Subscribe(_ => { if (listSettings.SelectedAuthor != null) { SelectedAuthor = Authors.FirstOrDefault(x => x.Login == listSettings.SelectedAuthor); } if (listSettings.SelectedAssignee != null) { SelectedAssignee = Assignees.FirstOrDefault(x => x.Login == listSettings.SelectedAssignee); } IsBusy = false; UpdateFilter(SelectedState, SelectedAssignee, SelectedAuthor, SearchQuery); }); return(Task.CompletedTask); }
public Author GetAuthorById(string authorId) { return(Authors.FirstOrDefault(author => author.AuthorId == authorId)); }
//-----------------------// // PodcastAuthor methods // //-----------------------// public Author GetPodcastAuthor(int id) { return(Authors.FirstOrDefault(x => x.Id == id)); }