public SiteModel(IShopRepository repository, int langId, string contentName, bool showSpecialOffers = false, string articleName = null) { _sw.Start(); Title = "Active Land"; IQueryable<Category> categories = null; categories = repository.GetCategories().OrderBy(c => c.SortOrder); Categories = categories.Include(c => c.Children).ToList(); //Categories = repository.GetCategories().Include(x=>x.Children).ToList(); foreach (var category in Categories) { category.CurrentLang = langId; } if (showSpecialOffers) SpecialOffers = GetSpecialOffers(repository, langId, int.Parse(SiteSettings.GetShopSetting("SpecialOffersQuantity"))); Contents = repository.GetContents(); Content = contentName != null ? (contentName == "category" ? repository.GetCatalogueContent() : repository.GetContent(contentName)) : repository.GetContent(); MainPageBanners = repository.GetMainPageBanners(); SiteBanners = repository.GetSiteBanners().OrderBy(p => Guid.NewGuid()).Take(2).ToList(); MainPageInfo = new MainPageInfo(); var authorAvatarImageSource = repository.GetSiteProperty("AuthorAvatarImageSource"); if (authorAvatarImageSource != null) { MainPageInfo.AuthorAvatarImageSource = authorAvatarImageSource.Value; } var authorGreetingText = repository.GetSiteProperty("AuthorGreetingText"); if (authorGreetingText != null) { MainPageInfo.AuthorGreetingText = authorGreetingText.Value; } if (Content.ContentType == 2) { Articles = GetAllArticles(repository, langId); } LastArticles = GetLastArticles(repository, langId, int.Parse(SiteSettings.GetShopSetting("ArticlesQuantity"))); QuickAdvices = repository.GetQuickAdvices(true); if (articleName != null) { this.Article = repository.GetArticle(articleName); } }
public ActionResult Edit(MainPageInfo model) { try { var avatarImageSource = _repository.GetSiteProperty("AuthorAvatarImageSource"); var authorGreetingText = _repository.GetSiteProperty("AuthorGreetingText"); if (authorGreetingText != null) { authorGreetingText.Value = HttpUtility.HtmlDecode(model.AuthorGreetingText); } _repository.SaveSiteProperty(authorGreetingText); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file == null) continue; if (string.IsNullOrEmpty(file.FileName)) continue; string fileName = IOHelper.GetUniqueFileName("~/Content/Images", file.FileName); string filePath = Server.MapPath("~/Content/Images"); filePath = Path.Combine(filePath, fileName); //GraphicsHelper.SaveOriginalImage(filePath, fileName, file, 1500); file.SaveAs(filePath); if (avatarImageSource != null) { if (!string.IsNullOrEmpty(avatarImageSource.Value)) { ImageHelper.DeleteImage(avatarImageSource.Value); } avatarImageSource.Value = fileName; } _repository.SaveSiteProperty(avatarImageSource); } return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult Edit() { var model = new MainPageInfo(); var avatarImageSource = _repository.GetSiteProperty("AuthorAvatarImageSource"); if (avatarImageSource != null) { model.AuthorAvatarImageSource = avatarImageSource.Value; } var authorGreetingText = _repository.GetSiteProperty("AuthorGreetingText"); if (authorGreetingText != null) { model.AuthorGreetingText = authorGreetingText.Value; } return View(model); }