Exemplo n.º 1
0
 public ActionResult FrontpageImage(int id)
 {
     Session["CurrentArticleId"] = id;
     Image image = db.Articles.Include(x => x.FrontpageImage).FirstOrDefault(x => x.Id == id).FrontpageImage;
     ImageViewModel model = new ImageViewModel(ArticleId, image);
     return View(model);
 }
Exemplo n.º 2
0
 public UserGroupViewModel(UserGroup usrGroup)
 {
     UserGroupId = usrGroup.UserGroupId;
     GroupName = usrGroup.GroupName;
     Sql = usrGroup.Sql;
     GroupType = usrGroup.GroupType;
     GroupImage = new ImageViewModel(usrGroup.UserGroupId, usrGroup.GroupImage);
     Users = usrGroup.Users;
     Administrators = usrGroup.Administrators;
 }
Exemplo n.º 3
0
        public ActionResult Slideshow(int id, int orderNr)
        {
            ArticleViewModel m = (ArticleViewModel)Session["CurrentArticleViewModel"];

            ImageViewModel image;
            if (orderNr >= 0) {
                image = m.Images.First(i => i.OrderNr == orderNr);
            } else
                image = new ImageViewModel(id, m.Article.FrontpageImage);

            image.IsFirst = orderNr == -1;
            image.IsLast = orderNr == (m.Images.Count() - 1);

            return View(image);
        }
Exemplo n.º 4
0
        protected override void WriteFile(HttpResponseBase response)
        {
            var items = new List<SyndicationItem>();

            foreach (Article article in articles) {
                var item = new SyndicationItem(article.Headline, null, new Uri("http://" + currentUrl.Host + "/Article/Article/" + article.Id)) {
                    Summary = new TextSyndicationContent(article.FrontpageText)
                };
                item.Categories.Add(new SyndicationCategory("News"));
                foreach (var category in article.Categories) {
                    item.Categories.Add(new SyndicationCategory(category.Name));
                }

                item.PublishDate = article.Date;

                item.Id = currentUrl.Host + "-" + article.Id;

                Image image = article.FrontpageImage;
                if (image != null) {
                    ImageViewModel ivm = new ImageViewModel(article.Id, image);
                    item.ElementExtensions.Add(new XElement("enclosure", new XAttribute("url", ivm.GetThumbUrl())));
                }

                items.Add(item);
            }

            SyndicationFeed feed = new SyndicationFeed(title, title, currentUrl, items.AsEnumerable());
            Rss20FeedFormatter formatter = new Rss20FeedFormatter(feed);

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            using (XmlWriter writer = XmlWriter.Create(response.Output, settings)) {
                formatter.WriteTo(writer);
            }
        }