public async Task <IActionResult> SiteMap() { var categories = new SiteMapViewModel { Categories = await this.categoryService.GetAllCategoriesAsync(), }; return(this.View(categories)); }
public IActionResult Setting(SettingViewModel model) { if (Request.Method.Equals("GET")) { model = new SettingViewModel(); UIUser usr = GetUserInfo(); model = new SettingViewModel(); model.SiteMaps = SiteMapsContext.LoadAllSiteMaps().Select(x => AutoMapperFactory.SiteMapViewModel_UISiteMap.CreateMapper().Map <SiteMapViewModel>(new UISiteMap(x))).ToList(); var item = model.SiteMaps.FirstOrDefault(x => x.SiteMapController.Equals(usr.DefaultController) && x.SiteMapView.Equals(usr.DefaultView)); item.IsSelected = true; return(View(model)); } else { UIUser usr = GetUserInfo(); SiteMapViewModel item = model.SiteMaps.FirstOrDefault(x => x.IsSelected); if (item == null) { ViewData["ErrorMessage"] = "Unhandled exception: item not found"; } else { bool update = false; try { update = SiteMapsContext.UpdateUserDefaultView(usr, AutoMapperFactory.SiteMapViewModel_UISiteMap.CreateMapper().Map <UISiteMap>(item)); } catch (Exception ex) { ViewData["ErrorMessage"] = ex.Message; } if (update) { ViewData["SuccessMessage"] = "Successfully updated the User Front Page..."; } else { ViewData["ErrorMessage"] = "Unhandled exception: failed to update the record"; } } return(View(model)); } }
public SiteMapViewModel GetSiteMapViewModel() { var model = new SiteMapViewModel(); model.Categories = (from p in Database.Categories orderby p.Name select new SiteMapViewModel.Category { Id = p.Id, Name = p.Name }).ToArray(); model.Products = (from p in Database.Products.ForSale() orderby p.Name select new SiteMapViewModel.Product { Id = p.Id, Name = p.Name }).ToArray(); return(model); }
/// <summary> /// Обрабатывается до вызыва экшена /// </summary> /// <param name="filterContext"></param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); ViewBag.ControllerName = (String)RouteData.Values["controller"]; ViewBag.ActionName = RouteData.Values["action"].ToString().ToLower(); model = new SiteMapViewModel { Account = AccountInfo, Settings = SettingsInfo, UserResolution = UserResolutionInfo, ControllerName = ControllerName, ActionName = ActionName, FrontSectionList = _cmsRepository.getSiteMapFrontSectionList(Domain), MenuTypes = _cmsRepository.getSiteMapMenuTypes() }; #region Метатеги ViewBag.Title = UserResolutionInfo.Title; ViewBag.Description = ""; ViewBag.KeyWords = ""; #endregion }
public ActionResult Item(Guid id, SiteMapViewModel back_model, HttpPostedFileBase upload) { ErrorMessage userMessage = new ErrorMessage { title = "Информация" }; #region Данные необходимые для сохранения back_model.Item.Id = id; if (string.IsNullOrEmpty(Request.Form["Item_ParentId"])) { back_model.Item.ParentId = null; } else { back_model.Item.ParentId = back_model.Item.ParentId != null ? back_model.Item.ParentId : Guid.Parse(Request.Form["Item_ParentId"]); // родительский id } var p = back_model.Item.ParentId != null?_cmsRepository.getSiteMapItem((Guid)back_model.Item.ParentId) : null; back_model.Item.Path = p == null ? "/" : p.Path + p.Alias + "/"; back_model.Item.Site = Domain; if (String.IsNullOrEmpty(back_model.Item.Alias)) { back_model.Item.Alias = Transliteration.Translit(back_model.Item.Title); } else { back_model.Item.Alias = Transliteration.Translit(back_model.Item.Alias); } if (_cmsRepository.existSiteMap(back_model.Item.Path, back_model.Item.Alias, back_model.Item.Id))// && back_model.Item.OldId!=null { model.ErrorInfo = new ErrorMessage() { title = "Ошибка", info = "Такой алиас на данном уровне уже существует, введите иное значение в поле Алиас", buttons = new ErrorMassegeBtn[] { new ErrorMassegeBtn { url = "#", text = "ок", action = "false", style = "primary" } } }; model.Item = back_model.Item; // хлебные крошки model.BreadCrumbs = _cmsRepository.getSiteMapBreadCrumbs(back_model.Item.ParentId); model.Item.ParentId = back_model.Item.ParentId; var _mg = new MultiSelectList(model.MenuTypes, "value", "text", model.Item?.MenuGroups); ViewBag.GroupMenu = _mg; return(View("Item", model)); } // хлебные крошки model.BreadCrumbs = _cmsRepository.getSiteMapBreadCrumbs(back_model.Item.ParentId); // список дочерних элементов model.Childrens = _cmsRepository.getSiteMapChildrens(id); #endregion //определяем занятость входного url if (!_cmsRepository.ckeckSiteMapAlias(back_model.Item.Alias, back_model.Item.ParentId.ToString(), id)) { if (ModelState.IsValid) { #region Сохранение изображение // путь для сохранения изображения string savePath = Settings.UserFiles + Domain + Settings.SiteMapDir; int width = 264; int height = 70; if (upload != null && upload.ContentLength > 0) { string fileExtension = upload.FileName.Substring(upload.FileName.LastIndexOf(".")).ToLower(); var validExtension = (!string.IsNullOrEmpty(Settings.PicTypes)) ? Settings.PicTypes.Split(',') : "jpg,jpeg,png,gif".Split(','); if (!validExtension.Contains(fileExtension.Replace(".", ""))) { model.Item = _cmsRepository.getSiteMapItem(id); model.ErrorInfo = new ErrorMessage() { title = "Ошибка", info = "Вы не можете загружать файлы данного формата", buttons = new ErrorMassegeBtn[] { new ErrorMassegeBtn { url = "#", text = "ок", action = "false", style = "primary" } } }; return(View("Item", model)); } Photo photoNew = new Photo() { Name = id.ToString() + fileExtension, Size = Files.FileAnliz.SizeFromUpload(upload), Url = Files.SaveImageResizeRename(upload, savePath, id.ToString(), width, height) }; back_model.Item.Photo = photoNew; } #endregion if (_cmsRepository.checkSiteMap(id)) { //Если запись заблокирована от редактирования некоторых полей var siteMapItem = _cmsRepository.getSiteMapItem(id); if (siteMapItem.Blocked && !model.Account.Group.ToLower().Equals("developer") && !model.Account.Group.ToLower().Equals("administrator")) { siteMapItem.Disabled = back_model.Item.Disabled; siteMapItem.DisabledMenu = back_model.Item.DisabledMenu; siteMapItem.Keyw = back_model.Item.Keyw; siteMapItem.Desc = back_model.Item.Desc; siteMapItem.Text = back_model.Item.Text; siteMapItem.Url = back_model.Item.Url; siteMapItem.ParentId = back_model.Item.ParentId; siteMapItem.MenuGroups = back_model.Item.MenuGroups; siteMapItem.Path = back_model.Item.Path; _cmsRepository.updateSiteMapItem(id, siteMapItem); } else { _cmsRepository.updateSiteMapItem(id, back_model.Item); //, AccountInfo.id, RequestUserInfo.IP } userMessage.info = "Запись обновлена"; } else { _cmsRepository.createSiteMapItem(id, back_model.Item); //, AccountInfo.id, RequestUserInfo.IP userMessage.info = "Запись добавлена"; } string backUrl = back_model.Item.ParentId != null ? "item/" + back_model.Item.ParentId : string.Empty; userMessage.buttons = new ErrorMassegeBtn[] { new ErrorMassegeBtn { url = StartUrl + backUrl, text = "Вернуться в список" }, new ErrorMassegeBtn { url = "/Admin/sitemap/item/" + id, text = "ок" } }; } else { userMessage.info = "Ошибка в заполнении формы. Поля в которых допушены ошибки - помечены цветом."; userMessage.buttons = new ErrorMassegeBtn[] { new ErrorMassegeBtn { url = "#", text = "ок", action = "false" } }; } } else { userMessage.info = "Элемент с таким алиасом на этом уровне уже существует"; userMessage.buttons = new ErrorMassegeBtn[] { new ErrorMassegeBtn { url = "#", text = "ок", action = "false" } }; } model.Item = _cmsRepository.getSiteMapItem(id); var mg = new MultiSelectList(model.MenuTypes, "value", "text", model.Item?.MenuGroups); ViewBag.GroupMenu = mg; var aviable = (model.MenuTypes != null) ? (model.MenuTypes.Where(t => t.available).Any()) ? model.MenuTypes.Where(t => t.available).ToArray() : new Catalog_list[] { } : new Catalog_list[] { }; var mgAviable = new MultiSelectList(aviable, "value", "text", model.Item != null ? model.Item.MenuGroups : null); ViewBag.GroupMenuAviable = mgAviable; model.Item.MenuGroups = null; model.ErrorInfo = userMessage; return(View(model)); }
public ViewResult Index(int?productTypeFilterId) { var customer = HttpContext.GetCustomer(); var settings = SiteMapSettingsProvider.LoadSiteMapSettings(); var viewModel = new SiteMapViewModel { ShowCategories = settings.ShowCategories, ShowManufacturers = settings.ShowManufacturers, ShowSections = settings.ShowSections, ShowTopics = settings.ShowTopics, ShowProducts = settings.ShowProducts, ShowCustomerService = settings.ShowCustomerService }; if (settings.ShowProducts) { // Using named routes drastically improves performance for sites with many products. var routingConfiguration = RoutingConfigurationProvider.GetRoutingConfiguration(); string productRouteName; if (routingConfiguration.LegacyRouteGenerationEnabled) { productRouteName = RouteNames.Product; } else if (routingConfiguration.SeNameOnlyRoutesEnabled) { productRouteName = RouteNames.ModernProductSeNameOnly; } else { productRouteName = RouteNames.ModernProduct; } using (var connection = new SqlConnection(DB.GetDBConn())) using (var command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "aspdnsf_GetProducts"; command.Parameters.AddWithValue("@CustomerLevelID", customer.CustomerLevelID); command.Parameters.AddWithValue("@affiliateID", customer.AffiliateID); command.Parameters.AddWithValue("@ProductTypeID", productTypeFilterId); command.Parameters.AddWithValue("@InventoryFilter", settings.InventoryThreshold); command.Parameters.AddWithValue("@localeName", customer.LocaleSetting); command.Parameters.AddWithValue("@storeID", customer.StoreID); command.Parameters.AddWithValue("@filterProduct", settings.ProductFiltering); command.Parameters.AddWithValue("@ViewType", 1); command.Parameters.AddWithValue("@pagenum", 1); command.Parameters.AddWithValue("@pagesize", 2147483647); command.Parameters.AddWithValue("@StatsFirst", 0); command.Parameters.AddWithValue("@publishedonly", 1); command.Parameters.AddWithValue("@ExcludeKits", 0); command.Parameters.AddWithValue("@ExcludeSysProds", 1); connection.Open(); using (var reader = command.ExecuteReader()) while (reader.Read()) { var id = reader.FieldInt("ProductID"); var localizedName = XmlCommon.GetLocaleEntry( reader.Field("name"), customer.LocaleSetting, fallBack: true); var seName = reader.Field("sename"); viewModel.Products.Add( new Models.SiteMapEntity { Name = localizedName, Url = Url.BuildProductLink(id, seName) }); } } } if (settings.ShowTopics) { using (var connection = DB.dbConn()) { connection.Open(); using (var reader = DB.GetRS( @"declare @storeSpecificTopics table ( topicid int, name varchar(max), title varchar(max), storeid int, displayorder int ) insert into @storeSpecificTopics select topicid, name, title, storeid, displayorder from topic as dt with (nolock) where showinsitemap = 1 and deleted = 0 and published = 1 and(storeid = @storeId) and @filterTopic = 1 select topicid, name, title, storeid, displayorder from topic as dt with (nolock) where showinsitemap = 1 and deleted = 0 and published = 1 and(storeid = 0) and name not in (select name from @storeSpecificTopics) union select * from @storeSpecificTopics order by displayorder, title" , connection, new SqlParameter("@filterTopic", settings.TopicFiltering), new SqlParameter("@storeId", customer.StoreID))) { while (reader.Read()) { var topicId = reader.FieldInt("topicid"); var name = reader.Field("name"); var localizedTitle = XmlCommon.GetLocaleEntry( reader.Field("title"), customer.LocaleSetting, fallBack: true); viewModel.Topics.Add( new Models.SiteMapEntity() { Name = localizedTitle, Url = Url.BuildTopicLink(name) }); } } } } if (settings.ShowCustomerService) { viewModel.CustomerService.Add( new Models.SiteMapEntity() { Name = AppLogic.GetString("menu.YourAccount"), Url = Url.Action(ActionNames.Index, ControllerNames.Account) }); viewModel.CustomerService.Add( new Models.SiteMapEntity() { Name = AppLogic.GetString("menu.OrderHistory"), Url = string.Concat( Url.Action(ActionNames.Index, ControllerNames.Account), "#orderhistory") }); viewModel.CustomerService.Add( new Models.SiteMapEntity() { Name = AppLogic.GetString("menu.Contact"), Url = Url.Action(ActionNames.Index, ControllerNames.ContactUs) }); } if (settings.ShowCategories) { EntityHelper entityHelper = new EntityHelper( CacheMinutes: 0, eSpecs: EntityDefinitions.LookupSpecs(EntityTypes.Category), PublishedOnly: true, StoreID: 0); viewModel.Categories = AddEntities( entityHelper .m_TblMgr .XmlDoc .SelectNodes("/root/Entity"), customer, EntityTypes.Category); } if (settings.ShowSections) { EntityHelper entityHelper = new EntityHelper( CacheMinutes: 0, eSpecs: EntityDefinitions.LookupSpecs(EntityTypes.Section), PublishedOnly: true, StoreID: 0); viewModel.Sections = AddEntities( entityHelper .m_TblMgr .XmlDoc .SelectNodes("/root/Entity"), customer, EntityTypes.Section); } if (settings.ShowManufacturers) { EntityHelper entityHelper = new EntityHelper( CacheMinutes: 0, eSpecs: EntityDefinitions.LookupSpecs(EntityTypes.Manufacturer), PublishedOnly: true, StoreID: 0); viewModel.Manufacturers = AddEntities( entityHelper .m_TblMgr .XmlDoc .SelectNodes("/root/Entity"), customer, EntityTypes.Manufacturer); } return(View(ViewNames.SiteMap, viewModel)); }