internal SyndicationFeed CreateUpdateFeed(UpdateFeedModel feedModel, Uri currentUri, UrlHelper urlHelper)
         {
            var updateFeed = new SyndicationFeed
            {
               Id = string.Format("tag:{0},{1:yyyy-MM-dd}:feed/utc-time/{1:HH:mm:ss}", currentUri.Host, feedModel.LastUpdateUtcDateTimeOffset),
               Language = "en",
               Title = SyndicationContent.CreatePlaintextContent("IT Training Manager"),
               Description = SyndicationContent.CreatePlaintextContent("New Courses"),
               LastUpdatedTime = feedModel.LastUpdateUtcDateTimeOffset,
               Links =
               {
                  SyndicationLink.CreateSelfLink(currentUri, "application/atom+xml"),
                  SyndicationLink.CreateAlternateLink(new UriBuilder{Scheme = currentUri.Scheme,Host = currentUri.Host,Port = currentUri.Port}.Uri,
                  "text/html")
               },
               Items = feedModel.Courses.Select(item =>
               {
                  var syndicationItem = new SyndicationItem
                  {
                     Id = item.GetCourseUri(urlHelper, currentUri.Scheme).ToString(),
                     Title = SyndicationContent.CreatePlaintextContent(item.CourseTitle),
                     Content = SyndicationContent.CreateHtmlContent(item.CourseDescription),
                     Links =
                     {
                        SyndicationLink.CreateAlternateLink(item.GetCourseUri(urlHelper, currentUri.Scheme), "text/html")
                     },
                     PublishDate = item.PublishedUtcDateOffset,
                     LastUpdatedTime = feedModel.LastUpdateUtcDateTimeOffset,
                     Categories =
                     {
                        new SyndicationCategory
                        {
                           Label = "/" + item.CategoryTitle,
                           Name = item.CategoryTitle,
                           Scheme = item.GetCategoryUriString(urlHelper, currentUri.Scheme)
                        }
                     }
                  };

                  foreach (var person in item.Authors)
                  {
                     syndicationItem.Authors.Add(new SyndicationPerson
                     {
                        Name = person.Title,
                        Uri = item.GetPersonUriString(person.UrlName, urlHelper, currentUri.Scheme)
                     });
                  }

                  foreach (var person in item.CoAuthors)
                  {
                     syndicationItem.Contributors.Add(new SyndicationPerson
                     {
                        Name = person.Title,
                        Uri = item.GetPersonUriString(person.UrlName, urlHelper, currentUri.Scheme)
                     });
                  }

                  return syndicationItem;
               })
            };

            return updateFeed;
         }
Ejemplo n.º 2
0
            internal SyndicationFeed CreateUpdateFeed(UpdateFeedModel feedModel, Uri currentUri, UrlHelper urlHelper)
            {
                var updateFeed = new SyndicationFeed
                {
                    Id              = string.Format("tag:{0},{1:yyyy-MM-dd}:feed/utc-time/{1:HH:mm:ss}", currentUri.Host, feedModel.LastUpdateUtcDateTimeOffset),
                    Language        = "en",
                    Title           = SyndicationContent.CreatePlaintextContent("IT Training Manager"),
                    Description     = SyndicationContent.CreatePlaintextContent("New Courses"),
                    LastUpdatedTime = feedModel.LastUpdateUtcDateTimeOffset,
                    Links           =
                    {
                        SyndicationLink.CreateSelfLink(currentUri, "application/atom+xml"),
                        SyndicationLink.CreateAlternateLink(new UriBuilder {
                            Scheme = currentUri.Scheme,            Host = currentUri.Host, Port= currentUri.Port
                        }.Uri,
                                                            "text/html")
                    },
                    Items = feedModel.Courses.Select(item =>
                    {
                        var syndicationItem = new SyndicationItem
                        {
                            Id      = item.GetCourseUri(urlHelper, currentUri.Scheme).ToString(),
                            Title   = SyndicationContent.CreatePlaintextContent(item.CourseTitle),
                            Content = SyndicationContent.CreateHtmlContent(item.CourseDescription),
                            Links   =
                            {
                                SyndicationLink.CreateAlternateLink(item.GetCourseUri(urlHelper, currentUri.Scheme), "text/html")
                            },
                            PublishDate     = item.PublishedUtcDateOffset,
                            LastUpdatedTime = feedModel.LastUpdateUtcDateTimeOffset,
                            Categories      =
                            {
                                new SyndicationCategory
                                {
                                    Label  = "/" + item.CategoryTitle,
                                    Name   = item.CategoryTitle,
                                    Scheme = item.GetCategoryUriString(urlHelper, currentUri.Scheme)
                                }
                            }
                        };

                        foreach (var person in item.Authors)
                        {
                            syndicationItem.Authors.Add(new SyndicationPerson
                            {
                                Name = person.Title,
                                Uri  = item.GetPersonUriString(person.UrlName, urlHelper, currentUri.Scheme)
                            });
                        }

                        foreach (var person in item.CoAuthors)
                        {
                            syndicationItem.Contributors.Add(new SyndicationPerson
                            {
                                Name = person.Title,
                                Uri  = item.GetPersonUriString(person.UrlName, urlHelper, currentUri.Scheme)
                            });
                        }

                        return(syndicationItem);
                    })
                };

                return(updateFeed);
            }