public static BlogModel Map(Blog blog) { return new BlogModel { Address = new Address { AddressLine = blog.Address.AddressLine, City = blog.Address.City, Country = blog.Address.Country, Zip = blog.Address.Zip }, Description = blog.Description, Email = blog.Email, Fax = blog.Fax, GeoPoint = new GeoPoint { Latitude = blog.GeoPoint.Latitude, Longitude = blog.GeoPoint.Longitude }, LogoUrl = blog.LogoUrl, Name = blog.Name, Phone = blog.Phone, StyleSheet = blog.StyleSheet, EnableNewsletter = blog.EnableNewsletter, ShowContactinfoInFooter = blog.ShowContactinfoInFooter, GoogleAnalyticsId = blog.GoogleAnalyticsId }; }
private void SetViewBag(Blog blog, ViewResult viewResult, User user) { if (blog == null) { blog = SetupNewBlog(); } _featureService = new FeatureService(_featureRepository); //var blogposts = _blogPostRepository.GetAll().Where(o => o.Published).ToList(); //var archiveModel = new ArchiveModel(); //var years = blogposts.Select(o => o.DateCreated.Year).Distinct().Select(i => new Year { Name = i }); //foreach (var year in years) //{ // var months = // blogposts.Where(o => o.DateCreated.Year == year.Name).Select(i => i.DateCreated.Month).Distinct(). // Select(y => new Month // { // Nr = y, // Name = new DateTime(DateTime.Now.Year, y, 1).ToString("MMM") // }); // foreach (var month in months) // { // var posts = // blogposts.Where(o => o.DateCreated.Year == year.Name && o.DateCreated.Month == month.Nr); // month.Posts.AddRange(posts.Select(o => new Article { Title = o.Title, Id = o.Id })); // month.Count = posts.Count(); // year.Months.Add(month); // } // year.Count = months.Count(); // archiveModel.Years.Add(year); //} viewResult.ViewBag.Title = blog.Name; viewResult.ViewBag.Logo = blog.LogoUrl; viewResult.ViewBag.Name = blog.Name; viewResult.ViewBag.Description = blog.Description; viewResult.ViewBag.Phone = blog.Phone; viewResult.ViewBag.Fax = blog.Fax; viewResult.ViewBag.Address = blog.Address.AddressLine; viewResult.ViewBag.Post = blog.Address.Zip + " " + blog.Address.City; viewResult.ViewBag.FullAddress = blog.Address.AddressLine + ", " + blog.Address.Zip + " " + blog.Address.City; viewResult.ViewBag.Email = blog.Email; viewResult.ViewBag.Lat = blog.GeoPoint.Latitude; viewResult.ViewBag.Lon = blog.GeoPoint.Longitude; viewResult.ViewBag.Menu = blog.Menu; viewResult.ViewBag.StyleSheet = blog.StyleSheet; viewResult.ViewBag.GoogleAnalyticsId = blog.GoogleAnalyticsId; viewResult.ViewBag.EnableNewsletter = _featureService.EnableNewsletter.IsEnabledForUser(user); viewResult.ViewBag.EnableTaggableContent = _featureService.EnableTaggableContent.IsEnabledForUser(user); viewResult.ViewBag.EnableUserLogin = _featureService.EnableUserLogin.IsEnabledForUser(user); viewResult.ViewBag.EnableSearch = _featureService.EnableSearch.IsEnabledForUser(user); //ViewBag.ShowContactinfoInFooter = blog.ShowContactinfoInFooter; //ViewBag.Tags = // blogposts.SelectMany(o => o.Tags).GroupBy(i => i).Select( // y => new TagModel { Name = y.Key, Count = y.Count() }); //ViewBag.Archive = archiveModel; //ViewBag.UserIsEditor = LoggedInUser != null && LoggedInUser.Groups.Any(o => o == "Admin"); viewResult.ViewBag.AllowedHtmlElements = "<h1><h2><h3><h4><a><ul><li><strong><b><u><i><p><img>"; }