internal libraryNaturguiden.News[] GetNews() { var value = db.News .OrderBy(x => x.Position) .OrderBy(x => x.Date) .Select(x => new libraryNaturguiden.News { Id = x.Id, Date = x.Date, Creator = x.Creator, Heading = x.Heading, Text = x.Text, PictureId = x.Picture == null ? 0 : (int)x.Picture, LinkUrl = x.LinkUrl, LinkText = x.LinkText, Position = x.Position }).ToArray(); var pictureHandler = new PictureHandler(); foreach (var item in value) { item.Picture = pictureHandler.GetPicture(item.PictureId); } return(value); }
internal libraryNaturguiden.News GetNews(int id) { var value = db.News .Where(x => x.Id == id) .Select(x => new libraryNaturguiden.News { Id = x.Id, Date = x.Date, Creator = x.Creator, Heading = x.Heading, Text = x.Text, PictureId = x.Picture == null ? 0 : (int)x.Picture, LinkUrl = x.LinkUrl, LinkText = x.LinkText, Position = x.Position }).FirstOrDefault(); var pictureHandler = new PictureHandler().GetPicture(value.PictureId); value.Picture = pictureHandler; return(value); }