public static List<LeftMenu> Load() { XmlDocument xml = new XmlDocument(); xml.Load(HttpContext.Current.Request.PhysicalApplicationPath + "/App_Data/Menu.config"); List<LeftMenu> menus = new List<LeftMenu>(); XmlNodeList menuNodes = xml.SelectNodes("Menus/Menu"); foreach (XmlNode menuNode in menuNodes) { LeftMenu menu = new LeftMenu(); menu.Code = menuNode.Attributes["code"].Value; menu.Title = menuNode.Attributes["title"].Value; menu.Href = menuNode.Attributes["href"].Value; menu.Img = menuNode.Attributes["img"].Value; foreach (XmlNode linkNode in menuNode.ChildNodes) { MenuLink link = new MenuLink(); link.Code = linkNode.Attributes["code"].Value; link.Title = linkNode.Attributes["title"].Value; link.Href = linkNode.Attributes["href"].Value; menu.Links.Add(link); } menus.Add(menu); } return menus; }
public static MenuLink ToMenuLink(this contentDto.MenuLink menuLinkDto) { var result = new MenuLink(); if (menuLinkDto.AssociatedObjectType != null) { if ("product" == menuLinkDto.AssociatedObjectType.ToLowerInvariant()) { result = new ProductMenuLink(); } else if ("category" == menuLinkDto.AssociatedObjectType.ToLowerInvariant()) { result = new CategoryMenuLink(); } } result.Id = menuLinkDto.Id; result.AssociatedObjectId = menuLinkDto.AssociatedObjectId; result.AssociatedObjectType = menuLinkDto.AssociatedObjectType; result.Priority = menuLinkDto.Priority ?? 0; result.Title = menuLinkDto.Title; result.Url = menuLinkDto.Url; return(result); }
public static MenuLink ToModel(this MenuLink entity) { if (entity == null) { return(null); } var model = new MenuLink { Id = entity.Id, ParentId = entity.ParentId, Status = entity.Status, TypeMenu = entity.TypeMenu, Position = entity.Position, MenuName = entity.GetLocalized(x => x.MenuName, entity.Id), SeoUrl = entity.SeoUrl, OrderDisplay = entity.OrderDisplay, ImageUrl = entity.ImageUrl, Icon1 = entity.Icon1, Icon2 = entity.Icon2, CurrentVirtualId = entity.CurrentVirtualId, VirtualId = entity.VirtualId, TemplateType = entity.TemplateType, MetaTitle = entity.GetLocalized(x => x.MetaTitle, entity.Id), MetaKeywords = entity.GetLocalized(x => x.MetaKeywords, entity.Id), MetaDescription = entity.GetLocalized(x => x.MetaDescription, entity.Id), Language = entity.Language, SourceLink = entity.SourceLink, VirtualSeoUrl = entity.VirtualSeoUrl, DisplayOnHomePage = entity.DisplayOnHomePage, DisplayOnMenu = entity.DisplayOnMenu, DisplayOnSearch = entity.DisplayOnSearch, }; return(model); }
public ActionResult Create(NewsViewModel model, string ReturnUrl) { ActionResult action; try { if (!base.ModelState.IsValid) { String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); base.ModelState.AddModelError("", messages); return(base.View(model)); } else { string str = model.Title.NonAccent(); IEnumerable <News> bySeoUrl = this._newsService.GetBySeoUrl(str); model.SeoUrl = model.Title.NonAccent(); if (bySeoUrl.Any <News>((News x) => x.Id != model.Id)) { NewsViewModel newsViewModel = model; newsViewModel.SeoUrl = string.Concat(newsViewModel.SeoUrl, "-", bySeoUrl.Count <News>()); } string str1 = string.Format("{0:ddMMyyyy}", DateTime.UtcNow); if (model.Image != null && model.Image.ContentLength > 0) { string str2 = string.Concat(str, ".jpg"); string str3 = string.Format("{0}-{1}.jpg", str, Guid.NewGuid()); string str4 = string.Format("{0}-{1}.jpg", str, Guid.NewGuid()); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.NewsFolder, str1), str2, new int?(ImageSize.WithBigSize), new int?(ImageSize.HeightBigSize), false); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.NewsFolder, str1), str3, new int?(ImageSize.WithMediumSize), new int?(ImageSize.HeightMediumSize), false); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.NewsFolder, str1), str4, new int?(ImageSize.WithSmallSize), new int?(ImageSize.HeightSmallSize), false); model.ImageBigSize = string.Format("{0}{1}/{2}", Contains.NewsFolder, str1, str2); model.ImageMediumSize = string.Format("{0}{1}/{2}", Contains.NewsFolder, str1, str3); model.ImageSmallSize = string.Format("{0}{1}/{2}", Contains.NewsFolder, str1, str4); } if (model.MenuId > 0) { MenuLink byId = this._menuLinkService.GetById(model.MenuId); model.VirtualCatUrl = byId.VirtualSeoUrl; model.VirtualCategoryId = byId.VirtualId; } News modelMap = Mapper.Map <NewsViewModel, News>(model); this._newsService.Create(modelMap); //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.ShortDesc, localized.ShortDesc, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.SeoUrl, localized.Title.NonAccent(), localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); } base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.News))); if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\")) { action = base.RedirectToAction("Index"); } else { action = this.Redirect(ReturnUrl); } } } catch (Exception exception1) { Exception exception = exception1; ExtentionUtils.Log(string.Concat("Post.Create: ", exception.Message)); base.ModelState.AddModelError("", exception.Message); return(base.View(model)); } return(action); }
public ActionResult Create(PostViewModel model, string ReturnUrl) { ActionResult action; try { if (!base.ModelState.IsValid) { String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); base.ModelState.AddModelError("", messages); return(base.View(model)); } else //if (!this._postService.FindBy((Post x) => x.ProductCode.Equals(model.ProductCode), true).IsAny<Post>()) { string str = model.Title.NonAccent(); IEnumerable <Post> bySeoUrl = this._postService.GetBySeoUrl(str); model.SeoUrl = model.Title.NonAccent(); if (bySeoUrl.Any <Post>((Post x) => x.Id != model.Id)) { PostViewModel postViewModel = model; postViewModel.SeoUrl = string.Concat(postViewModel.SeoUrl, "-", bySeoUrl.Count <Post>()); } string str1 = str; if (str1.Length > 250) { str1 = AdminHelper.SplitWords(250, str1); } string str2 = string.Format("{0:ddMMyyyy}", DateTime.UtcNow); if (model.Image != null && model.Image.ContentLength > 0) { string str3 = string.Concat(str1, ".jpg"); string str4 = string.Format("{0}-{1}.jpg", str1, Guid.NewGuid()); string str5 = string.Format("{0}-{1}.jpg", str1, Guid.NewGuid()); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.PostFolder, str2), str3, new int?(ImageSize.WithBigSize), new int?(ImageSize.HeightBigSize), false); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.PostFolder, str2), str4, new int?(ImageSize.WithMediumSize), new int?(ImageSize.HeightMediumSize), false); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.PostFolder, str2), str5, new int?(ImageSize.WithSmallSize), new int?(ImageSize.HeightSmallSize), false); model.ImageBigSize = string.Format("{0}{1}/{2}", Contains.PostFolder, str2, str3); model.ImageMediumSize = string.Format("{0}{1}/{2}", Contains.PostFolder, str2, str4); model.ImageSmallSize = string.Format("{0}{1}/{2}", Contains.PostFolder, str2, str5); } int?menuId = model.MenuId; int i = 0; if ((menuId.GetValueOrDefault() > i ? menuId.HasValue : false)) { IMenuLinkService menuLinkService = this._menuLinkService; menuId = model.MenuId; MenuLink byId = menuLinkService.GetById(menuId.Value); model.VirtualCatUrl = byId.VirtualSeoUrl; model.VirtualCategoryId = byId.VirtualId; } HttpFileCollectionBase files = base.Request.Files; List <GalleryImage> galleryImages = new List <GalleryImage>(); if (files.Count > 0) { int count = files.Count - 1; int num = 0; string str6 = str; string[] allKeys = files.AllKeys; for (i = 0; i < (int)allKeys.Length; i++) { string str7 = allKeys[i]; if (num <= count) { if (!str7.Equals("Image")) { string str8 = str7.Replace("[]", ""); HttpPostedFileBase item = files[num]; if (item.ContentLength > 0) { string item1 = base.Request[str8]; GalleryImageViewModel galleryImageViewModel = new GalleryImageViewModel() { PostId = model.Id, AttributeValueId = int.Parse(str8) }; string str9 = string.Format("{0}-{1}.jpg", str6, Guid.NewGuid()); string str10 = string.Format("{0}-{1}.jpg", str6, Guid.NewGuid()); this._imagePlugin.CropAndResizeImage(item, string.Format("{0}{1}/", Contains.PostFolder, str2), str9, new int?(ImageSize.WithBigSize), new int?(ImageSize.HeightBigSize), false); this._imagePlugin.CropAndResizeImage(item, string.Format("{0}{1}/", Contains.PostFolder, str2), str10, new int?(ImageSize.WithThumbnailSize), new int?(ImageSize.HeightThumbnailSize), false); galleryImageViewModel.ImageThumbnail = string.Format("{0}{1}/{2}", Contains.PostFolder, str2, str10); galleryImageViewModel.ImagePath = string.Format("{0}{1}/{2}", Contains.PostFolder, str2, str9); galleryImageViewModel.OrderDisplay = num; galleryImageViewModel.Status = 1; galleryImageViewModel.Title = model.Title; galleryImageViewModel.Price = new double?(double.Parse(item1)); galleryImages.Add(Mapper.Map <GalleryImage>(galleryImageViewModel)); } num++; } else { num++; } } } } List <AttributeValue> attributeValues = new List <AttributeValue>(); string item2 = base.Request["Values"]; if (!string.IsNullOrEmpty(item2)) { foreach (string list in item2.Split(new char[] { ',' }).ToList <string>()) { int num1 = int.Parse(list); attributeValues.Add(this._attributeValueService.GetById(num1)); } } Post modelMap = Mapper.Map <PostViewModel, Post>(model); if (galleryImages.IsAny <GalleryImage>()) { modelMap.GalleryImages = galleryImages; } if (attributeValues.IsAny <AttributeValue>()) { modelMap.AttributeValues = attributeValues; } this._postService.Create(modelMap); //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.ProductCode, localized.ProductCode, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.ShortDesc, localized.ShortDesc, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.TechInfo, localized.TechInfo, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.SeoUrl, localized.SeoUrl, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); } base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.Post))); if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\")) { action = base.RedirectToAction("Index"); } else { action = this.Redirect(ReturnUrl); } } //else //{ // base.ModelState.AddModelError("", "Mã sản phẩm đã tồn tại."); // action = base.View(model); //} } catch (Exception exception1) { Exception exception = exception1; ExtentionUtils.Log(string.Concat("Post.Create: ", exception.Message)); base.ModelState.AddModelError("", exception.Message); return(base.View(model)); } return(action); }
public ActionResult Create(MenuLinkViewModel model, string ReturnUrl) { ActionResult action; try { if (!base.ModelState.IsValid) { String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); base.ModelState.AddModelError("", messages); return(base.View(model)); } else { string str = model.MenuName.NonAccent(); IEnumerable <MenuLink> bySeoUrl = this._menuLinkService.GetListSeoUrl(str); model.SeoUrl = model.MenuName.NonAccent(); if (bySeoUrl.Any <MenuLink>((MenuLink x) => x.Id != model.Id)) { MenuLinkViewModel menuLinkViewModel = model; string seoUrl = menuLinkViewModel.SeoUrl; int num = bySeoUrl.Count <MenuLink>(); menuLinkViewModel.SeoUrl = string.Concat(seoUrl, "-", num.ToString()); } if (model.Image != null && model.Image.ContentLength > 0) { string fileName = Path.GetFileName(model.Image.FileName); string extension = Path.GetExtension(model.Image.FileName); fileName = string.Concat(model.MenuName.NonAccent(), extension); string str1 = Path.Combine(base.Server.MapPath(string.Concat("~/", Contains.ImageFolder)), fileName); model.Image.SaveAs(str1); model.ImageUrl = string.Concat(Contains.ImageFolder, fileName); } if (model.ImageIcon1 != null && model.ImageIcon1.ContentLength > 0) { string fileName1 = Path.GetFileName(model.ImageIcon1.FileName); string extension1 = Path.GetExtension(model.ImageIcon1.FileName); fileName1 = string.Concat(string.Concat(model.MenuName, "-icon").NonAccent(), extension1); string str2 = Path.Combine(base.Server.MapPath(string.Concat("~/", Contains.ImageFolder)), fileName1); model.ImageIcon1.SaveAs(str2); model.Icon1 = string.Concat(Contains.ImageFolder, fileName1); } if (model.ImageIcon2 != null && model.ImageIcon2.ContentLength > 0) { string fileName2 = Path.GetFileName(model.ImageIcon2.FileName); string extension2 = Path.GetExtension(model.ImageIcon2.FileName); fileName2 = string.Concat(string.Concat(model.MenuName, "-iconbar").NonAccent(), extension2); string str3 = Path.Combine(base.Server.MapPath(string.Concat("~/", Contains.ImageFolder)), fileName2); model.ImageIcon2.SaveAs(str3); model.Icon2 = string.Concat(Contains.ImageFolder, fileName2); } if (model.ParentId.HasValue) { string str4 = Guid.NewGuid().ToString(); model.CurrentVirtualId = str4; MenuLink byId = this._menuLinkService.GetById(model.ParentId.Value); model.VirtualId = string.Format("{0}/{1}", byId.VirtualId, str4); model.VirtualSeoUrl = string.Format("{0}/{1}", byId.SeoUrl, model.SeoUrl); } else { string str5 = Guid.NewGuid().ToString(); model.VirtualId = str5; model.CurrentVirtualId = str5; } MenuLink modelMap = Mapper.Map <MenuLinkViewModel, MenuLink>(model); this._menuLinkService.Create(modelMap); //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MenuName, localized.MenuName, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.SeoUrl, localized.MenuName.NonAccent(), localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); } base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.MenuLink))); if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\")) { action = base.RedirectToAction("Index"); } else { action = this.Redirect(ReturnUrl); } } } catch (Exception exception1) { Exception exception = exception1; ExtentionUtils.Log(string.Concat("MailSetting.Create: ", exception.Message)); return(base.View(model)); } return(action); }
private void OnEnable () { _target = (MenuLink) target; }
public ActionResult Edit(NewsViewModel model, string ReturnUrl) { ActionResult action; try { if (!base.ModelState.IsValid) { String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); base.ModelState.AddModelError("", messages); return(base.View(model)); } else { News byId = this._newsService.GetById(model.Id, isCache: false); string titleNonAccent = model.Title.NonAccent(); IEnumerable <MenuLink> bySeoUrl = this._menuLinkService.GetListSeoUrl(titleNonAccent, isCache: false); model.SeoUrl = model.Title.NonAccent(); if (bySeoUrl.Any <MenuLink>((MenuLink x) => x.Id != model.Id)) { NewsViewModel newsViewModel = model; newsViewModel.SeoUrl = string.Concat(newsViewModel.SeoUrl, "-", bySeoUrl.Count <MenuLink>()); } string folderName = string.Format("{0:ddMMyyyy}", DateTime.UtcNow); if (model.Image != null && model.Image.ContentLength > 0) { string fileExtension = Path.GetExtension(model.Image.FileName); string fileName1 = string.Concat(titleNonAccent, ".jpg"); string fileName2 = string.Format("{0}-{1}.jpg", titleNonAccent, Guid.NewGuid()); string fileName3 = string.Format("{0}-{1}.jpg", titleNonAccent, Guid.NewGuid()); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.NewsFolder, folderName), fileName1, ImageSize.WithBigSize, ImageSize.HeightBigSize, false); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.NewsFolder, folderName), fileName2, ImageSize.WithMediumSize, ImageSize.HeightMediumSize, false); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.NewsFolder, folderName), fileName3, ImageSize.WithSmallSize, ImageSize.HeightSmallSize, false); model.ImageBigSize = string.Format("{0}{1}/{2}", Contains.NewsFolder, folderName, fileName1); model.ImageMediumSize = string.Format("{0}{1}/{2}", Contains.NewsFolder, folderName, fileName2); model.ImageSmallSize = string.Format("{0}{1}/{2}", Contains.NewsFolder, folderName, fileName3); } if (model.MenuId > 0) { MenuLink menuLink = this._menuLinkService.GetById(model.MenuId, isCache: false); model.VirtualCatUrl = menuLink.VirtualSeoUrl; model.VirtualCategoryId = menuLink.VirtualId; model.MenuLink = Mapper.Map <MenuLink, MenuLinkViewModel>(menuLink); } News modelMap = Mapper.Map(model, byId); this._newsService.Update(modelMap); //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.ShortDesc, localized.ShortDesc, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.SeoUrl, localized.Title.NonAccent(), localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); } base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.News))); if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\")) { action = base.RedirectToAction("Index"); } else { action = this.Redirect(ReturnUrl); } } } catch (Exception ex) { base.ModelState.AddModelError("", ex.Message); ExtentionUtils.Log(string.Concat("News.Edit: ", ex.Message)); return(base.View(model)); } return(action); }
public async Task <bool> UpdateAsync(int id, MenuLink model) { await repository.UpdateAsync(id, model); return(true); }
public ActionResult Create(StaticContentViewModel model, string ReturnUrl) { ActionResult action; try { if (!base.ModelState.IsValid) { String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); base.ModelState.AddModelError("", messages); return(base.View(model)); } else { string titleNonAccent = model.Title.NonAccent(); IEnumerable <StaticContent> bySeoUrl = this._staticContentService.GetBySeoUrl(titleNonAccent, isCache: false); model.SeoUrl = model.Title.NonAccent(); if (bySeoUrl.Any <StaticContent>((StaticContent x) => x.Id != model.Id)) { StaticContentViewModel staticContentViewModel = model; staticContentViewModel.SeoUrl = string.Concat(staticContentViewModel.SeoUrl, "-", bySeoUrl.Count <StaticContent>()); } if (model.Image != null && model.Image.ContentLength > 0) { string fileName = Path.GetFileName(model.Image.FileName); string extension = Path.GetExtension(model.Image.FileName); fileName = fileName.FileNameFormat(extension); string str = Path.Combine(base.Server.MapPath(string.Concat("~/", Contains.ImageFolder)), fileName); model.Image.SaveAs(str); model.ImagePath = string.Concat(Contains.ImageFolder, fileName); } if (model.MenuId > 0) { MenuLink menuLink = this._menuLinkService.GetById(model.MenuId, isCache: false); model.MenuLink = Mapper.Map <MenuLink, MenuLinkViewModel>(menuLink); model.VirtualCategoryId = menuLink.VirtualId; } StaticContent modelMap = Mapper.Map <StaticContentViewModel, StaticContent>(model); this._staticContentService.Create(modelMap); //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.ShortDesc, localized.ShortDesc, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.SeoUrl, localized.Title.NonAccent(), localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); } base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.StaticContent))); if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\")) { action = base.RedirectToAction("Index"); } else { action = this.Redirect(ReturnUrl); } } } catch (Exception exception1) { Exception exception = exception1; ExtentionUtils.Log(string.Concat("Post.Create: ", exception.Message)); base.ModelState.AddModelError("", exception.Message); return(base.View(model)); } return(action); }
private void OnEnable() { _target = (MenuLink)target; }
public ActionResult PostDetail(string seoUrl) { int languageId = _workContext.WorkingLanguage.Id; List <BreadCrumb> breadCrumbs = new List <BreadCrumb>(); Post post = this._postService.Get((Post x) => x.SeoUrl.Equals(seoUrl), false); if (post == null) { return(HttpNotFound()); } Post postLocalized = null; if (post != null) { postLocalized = new Post { Id = post.Id, MenuId = post.MenuId, VirtualCategoryId = post.VirtualCategoryId, Language = post.Language, Status = post.Status, SeoUrl = post.SeoUrl, ImageBigSize = post.ImageBigSize, ImageMediumSize = post.ImageMediumSize, ImageSmallSize = post.ImageSmallSize, Price = post.Price, Discount = post.Discount, ProductHot = post.ProductHot, OutOfStock = post.OutOfStock, ProductNew = post.ProductNew, VirtualCatUrl = post.VirtualCatUrl, StartDate = post.StartDate, PostType = post.PostType, OldOrNew = post.OldOrNew, MenuLink = post.MenuLink, Title = post.GetLocalizedByLocaleKey(post.Title, post.Id, languageId, "Post", "Title"), ProductCode = post.GetLocalizedByLocaleKey(post.ProductCode, post.Id, languageId, "Post", "ProductCode"), TechInfo = post.GetLocalizedByLocaleKey(post.TechInfo, post.Id, languageId, "Post", "TechInfo"), ShortDesc = post.GetLocalizedByLocaleKey(post.ShortDesc, post.Id, languageId, "Post", "ShortDesc"), Description = post.GetLocalizedByLocaleKey(post.Description, post.Id, languageId, "Post", "Description"), MetaTitle = post.GetLocalizedByLocaleKey(post.MetaTitle, post.Id, languageId, "Post", "MetaTitle"), MetaKeywords = post.GetLocalizedByLocaleKey(post.MetaKeywords, post.Id, languageId, "Post", "MetaKeywords"), MetaDescription = post.GetLocalizedByLocaleKey(post.MetaDescription, post.Id, languageId, "Post", "MetaDescription") }; Post viewCount = post; viewCount.ViewCount = viewCount.ViewCount + 1; this._postService.Update(post); string[] strArrays = post.VirtualCategoryId.Split(new char[] { '/' }); for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; MenuLink menuLink = this._menuLinkService.Get((MenuLink x) => x.CurrentVirtualId.Equals(str), false); breadCrumbs.Add(new BreadCrumb() { Title = menuLink.GetLocalizedByLocaleKey(menuLink.MenuName, menuLink.Id, languageId, "MenuLink", "MenuName"), Current = false, Url = base.Url.Action("GetContent", "Menu", new { area = "", menu = menuLink.SeoUrl }) }); } breadCrumbs.Add(new BreadCrumb() { Current = true, Title = postLocalized.Title }); ((dynamic)base.ViewBag).BreadCrumb = breadCrumbs; ((dynamic)base.ViewBag).Title = postLocalized.Title; ((dynamic)base.ViewBag).KeyWords = postLocalized.MetaKeywords; ((dynamic)base.ViewBag).SiteUrl = base.Url.Action("PostDetail", "Post", new { seoUrl = seoUrl, area = "" }); ((dynamic)base.ViewBag).Description = postLocalized.MetaTitle; ((dynamic)base.ViewBag).Image = base.Url.Content(string.Concat("~/", postLocalized.ImageMediumSize)); ((dynamic)base.ViewBag).MenuId = postLocalized.MenuId; } return(base.View(postLocalized)); }
public ActionResult GetPostByCategory(string virtualCategoryId, int page, string title, string attrs, string prices, string proattrs, string keywords) { int languageId = _workContext.WorkingLanguage.Id; List <BreadCrumb> breadCrumbs = new List <BreadCrumb>(); Expression <Func <Post, bool> > expression = PredicateBuilder.True <Post>(); expression = expression.And <Post>((Post x) => x.Status == 1); SortBuilder sortBuilder = new SortBuilder() { ColumnName = "CreatedDate", ColumnOrder = SortBuilder.SortOrder.Descending }; Paging paging = new Paging() { PageNumber = page, PageSize = base._pageSize, TotalRecord = 0 }; if (page == 1) { dynamic viewBag = base.ViewBag; IPostService postService = this._postService; Expression <Func <Post, bool> > productNew = (Post x) => x.ProductNew && x.Status == 1; viewBag.HotCard = postService.GetTop <DateTime>(3, productNew, (Post x) => x.CreatedDate).ToList <Post>(); } if (!string.IsNullOrEmpty(attrs)) { string[] strArrays = attrs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <int> list = ( from s in strArrays select int.Parse(s)).ToList <int>(); expression = expression.And <Post>((Post x) => x.AttributeValues.Count <AttributeValue>((AttributeValue a) => list.Contains(a.Id)) > 0); ((dynamic)base.ViewBag).Attributes = list; } if (!string.IsNullOrEmpty(prices)) { List <double> nums = ( from s in prices.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) select double.Parse(s)).ToList <double>(); double item = nums[0]; double num = nums[1]; expression = expression.And <Post>((Post x) => x.Price >= (double?)item && x.Price <= (double?)num); ((dynamic)base.ViewBag).Prices = nums; } if (!string.IsNullOrEmpty(proattrs)) { string[] strArrays1 = proattrs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <int> list1 = ( from s in strArrays1 select int.Parse(s)).ToList <int>(); expression = expression.And <Post>((Post x) => list1.Contains(x.Id)); ((dynamic)base.ViewBag).ProAttributes = list1; } if (!string.IsNullOrEmpty(keywords)) { expression = expression.And <Post>((Post x) => x.Title.Contains(keywords)); } expression = expression.And <Post>((Post x) => x.VirtualCategoryId.Contains(virtualCategoryId)); IEnumerable <Post> posts = this._postService.FindAndSort(expression, sortBuilder, paging); if (posts == null) { return(HttpNotFound()); } string[] strArrays2 = virtualCategoryId.Split(new char[] { '/' }); for (int i1 = 0; i1 < (int)strArrays2.Length; i1++) { string str = strArrays2[i1]; MenuLink menuLink = this._menuLinkService.Get((MenuLink x) => x.CurrentVirtualId.Equals(str) && !x.MenuName.Equals(title), false); if (menuLink != null) { breadCrumbs.Add(new BreadCrumb() { Title = menuLink.GetLocalizedByLocaleKey(menuLink.MenuName, menuLink.Id, languageId, "MenuLink", "MenuName"), Current = false, Url = base.Url.Action("GetContent", "Menu", new { area = "", menu = menuLink.SeoUrl }) }); } } breadCrumbs.Add(new BreadCrumb() { Current = true, Title = title }); ((dynamic)base.ViewBag).BreadCrumb = breadCrumbs; IEnumerable <Post> postLocalized = null; if (posts.IsAny <Post>()) { postLocalized = from x in posts select new Post() { Id = x.Id, MenuId = x.MenuId, VirtualCategoryId = x.VirtualCategoryId, Language = x.Language, Status = x.Status, SeoUrl = x.SeoUrl, ImageBigSize = x.ImageBigSize, ImageMediumSize = x.ImageMediumSize, ImageSmallSize = x.ImageSmallSize, Price = x.Price, Discount = x.Discount, ProductHot = x.ProductHot, OutOfStock = x.OutOfStock, ProductNew = x.ProductNew, VirtualCatUrl = x.VirtualCatUrl, StartDate = x.StartDate, PostType = x.PostType, OldOrNew = x.OldOrNew, MenuLink = x.MenuLink, Title = x.GetLocalizedByLocaleKey(x.Title, x.Id, languageId, "Post", "Title"), ProductCode = x.GetLocalizedByLocaleKey(x.ProductCode, x.Id, languageId, "Post", "ProductCode"), TechInfo = x.GetLocalizedByLocaleKey(x.TechInfo, x.Id, languageId, "Post", "TechInfo"), ShortDesc = x.GetLocalizedByLocaleKey(x.ShortDesc, x.Id, languageId, "Post", "ShortDesc"), Description = x.GetLocalizedByLocaleKey(x.Description, x.Id, languageId, "Post", "Description"), MetaTitle = x.GetLocalizedByLocaleKey(x.MetaTitle, x.Id, languageId, "Post", "MetaTitle"), MetaKeywords = x.GetLocalizedByLocaleKey(x.MetaKeywords, x.Id, languageId, "Post", "MetaKeywords"), MetaDescription = x.GetLocalizedByLocaleKey(x.MetaDescription, x.Id, languageId, "Post", "MetaDescription") }; Helper.PageInfo pageInfo = new Helper.PageInfo(ExtentionUtils.PageSize, page, paging.TotalRecord, (int i) => base.Url.Action("GetContent", "Menu", new { page = i })); ((dynamic)base.ViewBag).PageInfo = pageInfo; ((dynamic)base.ViewBag).CountItem = pageInfo.TotalItems; ((dynamic)base.ViewBag).MenuId = postLocalized.ElementAt(0).MenuId; } ((dynamic)base.ViewBag).Title = title; return(base.PartialView(postLocalized)); }
public ActionResult NewsDetail(string seoUrl) { int languageId = _workContext.WorkingLanguage.Id; dynamic viewBag = base.ViewBag; IStaticContentService staticContentService = this._staticContentService; Expression <Func <StaticContent, bool> > status = (StaticContent x) => x.Status == 1; viewBag.fixItems = staticContentService.GetTop <int>(3, status, (StaticContent x) => x.ViewCount); List <BreadCrumb> breadCrumbs = new List <BreadCrumb>(); News news = this._newsService.Get((News x) => x.SeoUrl.Equals(seoUrl), true); if (news == null) { return(HttpNotFound()); } News newsLocalized = new News(); if (news != null) { newsLocalized = new News { Id = news.Id, MenuId = news.MenuId, VirtualCategoryId = news.VirtualCategoryId, Language = news.Language, Status = news.Status, SeoUrl = news.SeoUrl, ImageBigSize = news.ImageBigSize, ImageMediumSize = news.ImageMediumSize, ImageSmallSize = news.ImageSmallSize, MenuLink = news.MenuLink, CreatedDate = news.CreatedDate, Title = news.GetLocalizedByLocaleKey(news.Title, news.Id, languageId, "News", "Title"), ShortDesc = news.GetLocalizedByLocaleKey(news.ShortDesc, news.Id, languageId, "News", "ShortDesc"), Description = news.GetLocalizedByLocaleKey(news.Description, news.Id, languageId, "News", "Description"), MetaTitle = news.GetLocalizedByLocaleKey(news.MetaTitle, news.Id, languageId, "News", "MetaTitle"), MetaKeywords = news.GetLocalizedByLocaleKey(news.MetaKeywords, news.Id, languageId, "News", "MetaKeywords"), MetaDescription = news.GetLocalizedByLocaleKey(news.MetaDescription, news.Id, languageId, "News", "MetaDescription") }; ((dynamic)base.ViewBag).Title = newsLocalized.MetaTitle; ((dynamic)base.ViewBag).KeyWords = newsLocalized.MetaKeywords; ((dynamic)base.ViewBag).SiteUrl = base.Url.Action("NewsDetail", "News", new { seoUrl = seoUrl, area = "" }); ((dynamic)base.ViewBag).Description = newsLocalized.MetaDescription; ((dynamic)base.ViewBag).Image = base.Url.Content(string.Concat("~/", newsLocalized.ImageMediumSize)); ((dynamic)base.ViewBag).MenuId = newsLocalized.MenuId; string[] strArrays = newsLocalized.VirtualCategoryId.Split(new char[] { '/' }); for (int i = 0; i < (int)strArrays.Length; i++) { string str = strArrays[i]; MenuLink menuLink = this._menuLinkService.Get((MenuLink x) => x.CurrentVirtualId.Equals(str), false); breadCrumbs.Add(new BreadCrumb() { Title = menuLink.GetLocalizedByLocaleKey(menuLink.MenuName, menuLink.Id, languageId, "MenuLink", "MenuName"), Current = false, Url = base.Url.Action("GetContent", "Menu", new { area = "", menu = menuLink.SeoUrl }) }); } breadCrumbs.Add(new BreadCrumb() { Current = true, Title = newsLocalized.Title }); ((dynamic)base.ViewBag).BreadCrumb = breadCrumbs; } ((dynamic)base.ViewBag).SeoUrl = newsLocalized.MenuLink.SeoUrl; return(base.View(newsLocalized)); }
public ActionResult GetNewsByCategory(string virtualCategoryId, int?menuId, string title, int page) { int languageId = _workContext.WorkingLanguage.Id; ((dynamic)base.ViewBag).MenuId = menuId; ((dynamic)base.ViewBag).VirtualId = virtualCategoryId; dynamic viewBag = base.ViewBag; IStaticContentService staticContentService = this._staticContentService; Expression <Func <StaticContent, bool> > status = (StaticContent x) => x.Status == 1; viewBag.fixItems = staticContentService.GetTop <int>(3, status, (StaticContent x) => x.ViewCount); SortBuilder sortBuilder = new SortBuilder() { ColumnName = "CreatedDate", ColumnOrder = SortBuilder.SortOrder.Descending }; Paging paging = new Paging() { PageNumber = page, PageSize = base._pageSize, TotalRecord = 0 }; IEnumerable <News> news = this._newsService.FindAndSort((News x) => !x.Video && x.Status == 1 && x.VirtualCategoryId.Contains(virtualCategoryId), sortBuilder, paging); if (news == null) { return(HttpNotFound()); } IEnumerable <News> newsLocalized = news .Select(x => { return(x.ToModel()); }); if (news.IsAny()) { Helper.PageInfo pageInfo = new Helper.PageInfo(ExtentionUtils.PageSize, page, paging.TotalRecord, (int i) => base.Url.Action("GetContent", "Menu", new { page = i })); ((dynamic)base.ViewBag).PageInfo = pageInfo; ((dynamic)base.ViewBag).CountItem = pageInfo.TotalItems; MenuLink menuLink = null; List <BreadCrumb> breadCrumbs = new List <BreadCrumb>(); string[] strArrays2 = virtualCategoryId.Split(new char[] { '/' }); for (int i1 = 0; i1 < (int)strArrays2.Length; i1++) { string str = strArrays2[i1]; menuLink = this._menuLinkService.Get((MenuLink x) => x.CurrentVirtualId.Equals(str) && x.Id != menuId, false); if (menuLink != null) { breadCrumbs.Add(new BreadCrumb() { Title = menuLink.GetLocalizedByLocaleKey(menuLink.MenuName, menuLink.Id, languageId, "MenuLink", "MenuName"), Current = false, Url = base.Url.Action("GetContent", "Menu", new { area = "", menu = menuLink.SeoUrl }) }); } } breadCrumbs.Add(new BreadCrumb() { Current = true, Title = title }); ((dynamic)base.ViewBag).BreadCrumb = breadCrumbs; } ((dynamic)base.ViewBag).Title = title; return(base.PartialView(newsLocalized)); }
public FooterLinks() { Disclosure = new Models.MenuLink(); }
public void Open() { MenuLink.Click(); WairForMenu(); _logger.Debug("Side menu was opened."); }
public ActionResult Edit(PostViewModel model, string ReturnUrl) { ActionResult action; try { if (!base.ModelState.IsValid) { String messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); base.ModelState.AddModelError("", messages); return(base.View(model)); } else if (!_postService.FindBy((Post x) => x.ProductCode.Equals(model.ProductCode) && x.Id != model.Id, true).IsAny <Post>()) { Post byId = this._postService.GetById(model.Id, isCache: false); string titleNonAccent = model.Title.NonAccent(); IEnumerable <MenuLink> bySeoUrl = this._menuLinkService.GetListSeoUrl(titleNonAccent, isCache: false); model.SeoUrl = model.Title.NonAccent(); if (bySeoUrl.Any <MenuLink>((MenuLink x) => x.Id != model.Id)) { PostViewModel postViewModel = model; postViewModel.SeoUrl = string.Concat(postViewModel.SeoUrl, "-", bySeoUrl.Count <MenuLink>()); } //string str1 = titleNonAccent; //if (str1.Length > 250) //{ // str1 = Utils.Utils.SplitWords(250, str1); //} string folderName = string.Format("{0:ddMMyyyy}", DateTime.UtcNow); if (model.Image != null && model.Image.ContentLength > 0) { string fileExtension = Path.GetExtension(model.Image.FileName); string fileName1 = titleNonAccent.FileNameFormat(fileExtension); string fileName2 = titleNonAccent.FileNameFormat(fileExtension); string fileName3 = titleNonAccent.FileNameFormat(fileExtension); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.PostFolder, folderName), fileName1, ImageSize.WithBigSize, ImageSize.HeightBigSize, false); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.PostFolder, folderName), fileName2, ImageSize.WithMediumSize, ImageSize.HeightMediumSize, false); this._imagePlugin.CropAndResizeImage(model.Image, string.Format("{0}{1}/", Contains.PostFolder, folderName), fileName3, ImageSize.WithSmallSize, ImageSize.HeightSmallSize, false); model.ImageBigSize = string.Format("{0}{1}/{2}", Contains.PostFolder, folderName, fileName1); model.ImageMediumSize = string.Format("{0}{1}/{2}", Contains.PostFolder, folderName, fileName2); model.ImageSmallSize = string.Format("{0}{1}/{2}", Contains.PostFolder, folderName, fileName3); } int?menuId = model.MenuId; int i = 0; if ((menuId.GetValueOrDefault() > i ? menuId.HasValue : false)) { IMenuLinkService menuLinkService = this._menuLinkService; menuId = model.MenuId; MenuLink menuLink = menuLinkService.GetById(menuId.Value, isCache: false); model.VirtualCatUrl = menuLink.VirtualSeoUrl; model.VirtualCategoryId = menuLink.VirtualId; } //GalleryImage HttpFileCollectionBase files = base.Request.Files; List <GalleryImage> lstGalleryImages = new List <GalleryImage>(); if (files.Count > 0) { int count = files.Count - 1; int num = 0; string[] allKeys = files.AllKeys; for (i = 0; i < (int)allKeys.Length; i++) { string str7 = allKeys[i]; if (num <= count) { if (!str7.Equals("Image")) { string str8 = str7.Replace("[]", ""); HttpPostedFileBase item = files[num]; if (item.ContentLength > 0) { string item1 = base.Request[str8]; GalleryImageViewModel galleryImageViewModel = new GalleryImageViewModel() { PostId = model.Id, AttributeValueId = int.Parse(str8) }; string fileName1 = string.Format("{0}-{1}.jpg", titleNonAccent, Guid.NewGuid()); string fileName2 = string.Format("{0}-{1}.jpg", titleNonAccent, Guid.NewGuid()); this._imagePlugin.CropAndResizeImage(item, string.Format("{0}{1}/", Contains.PostFolder, folderName), fileName1, ImageSize.WithBigSize, ImageSize.WithBigSize, false); this._imagePlugin.CropAndResizeImage(item, string.Format("{0}{1}/", Contains.PostFolder, folderName), fileName2, ImageSize.WithThumbnailSize, ImageSize.HeightThumbnailSize, false); galleryImageViewModel.ImageThumbnail = string.Format("{0}{1}/{2}", Contains.PostFolder, folderName, fileName2); galleryImageViewModel.ImagePath = string.Format("{0}{1}/{2}", Contains.PostFolder, folderName, fileName1); galleryImageViewModel.OrderDisplay = num; galleryImageViewModel.Status = 1; galleryImageViewModel.Title = model.Title; galleryImageViewModel.Price = new double?(double.Parse(item1)); lstGalleryImages.Add(Mapper.Map <GalleryImage>(galleryImageViewModel)); } num++; } else { num++; } } } } if (lstGalleryImages.IsAny <GalleryImage>()) { byId.GalleryImages = lstGalleryImages; } //AttributeValue List <AttributeValue> lstAttributeValues = new List <AttributeValue>(); List <int> nums = new List <int>(); string item2 = base.Request["Values"]; if (!string.IsNullOrEmpty(item2)) { foreach (string list in item2.Split(new char[] { ',' }).ToList <string>()) { int num1 = int.Parse(list); nums.Add(num1); lstAttributeValues.Add(this._attributeValueService.GetById(num1, isCache: false)); } if (nums.IsAny <int>()) { ( from x in byId.AttributeValues where !nums.Contains(x.Id) select x).ToList <AttributeValue>().ForEach((AttributeValue att) => byId.AttributeValues.Remove(att)); } } byId.AttributeValues = lstAttributeValues; Post modelMap = Mapper.Map(model, byId); this._postService.Update(byId); //Update GalleryImage if (lstAttributeValues.IsAny <AttributeValue>()) { foreach (AttributeValue attributeValue in lstAttributeValues) { GalleryImage nullable = this._galleryService.Get((GalleryImage x) => x.AttributeValueId == attributeValue.Id && x.PostId == model.Id, false); if (nullable == null) { continue; } HttpRequestBase request = base.Request; i = attributeValue.Id; double num2 = double.Parse(request[i.ToString()]); nullable.Price = new double?(num2); this._galleryService.Update(nullable); } } //Update Localized foreach (var localized in model.Locales) { _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Title, localized.Title, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.ProductCode, localized.ProductCode, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.ShortDesc, localized.ShortDesc, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.Description, localized.Description, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.TechInfo, localized.TechInfo, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.SeoUrl, localized.SeoUrl, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaTitle, localized.MetaTitle, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaKeywords, localized.MetaKeywords, localized.LanguageId); _localizedPropertyService.SaveLocalizedValue(modelMap, x => x.MetaDescription, localized.MetaDescription, localized.LanguageId); } base.Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.Post))); if (!base.Url.IsLocalUrl(ReturnUrl) || ReturnUrl.Length <= 1 || !ReturnUrl.StartsWith("/") || ReturnUrl.StartsWith("//") || ReturnUrl.StartsWith("/\\")) { action = base.RedirectToAction("Index"); } else { action = this.Redirect(ReturnUrl); } } else { base.ModelState.AddModelError("", "Mã sản phẩm đã tồn tại."); action = base.View(model); } } catch (Exception ex) { base.ModelState.AddModelError("", ex.Message); ExtentionUtils.Log(string.Concat("Post.Edit: ", ex.Message)); return(base.View(model)); } return(action); }
public ActionResult CreatePost(PostViewModel post) { try { if (!base.ModelState.IsValid) { base.ModelState.AddModelError("", MessageUI.ErrorMessage); } else { string str = post.Title.NonAccent(); IEnumerable <Post> bySeoUrl = this._postService.GetBySeoUrl(str); post.SeoUrl = post.Title.NonAccent(); if (bySeoUrl.Any <Post>((Post x) => x.Id != post.Id)) { PostViewModel postViewModel = post; postViewModel.SeoUrl = string.Concat(postViewModel.SeoUrl, "-", bySeoUrl.Count <Post>()); } if (post.Image != null && post.Image.ContentLength > 0) { string str1 = string.Format("{0}-{1}", str, App.Utils.Utils.GetTime()); string str2 = string.Format("{0}-{1}", str, App.Utils.Utils.GetTime()); string str3 = string.Format("{0}-{1}", str, App.Utils.Utils.GetTime()); this._imagePlugin.CropAndResizeImage(post.Image, string.Format("{0}/{1}/", Contains.PostFolder, str), str1, new int?(ImageSize.WithBigSize), new int?(ImageSize.HeightBigSize), false); this._imagePlugin.CropAndResizeImage(post.Image, string.Format("{0}/{1}/", Contains.PostFolder, str), str2, new int?(ImageSize.WithMediumSize), new int?(ImageSize.HeightMediumSize), false); this._imagePlugin.CropAndResizeImage(post.Image, string.Format("{0}/{1}/", Contains.PostFolder, str), str3, new int?(ImageSize.WithSmallSize), new int?(ImageSize.HeightSmallSize), false); post.ImageBigSize = string.Format("{0}/{1}/{2}", Contains.PostFolder, str, str1); post.ImageMediumSize = string.Format("{0}/{1}/{2}", Contains.PostFolder, str, str2); post.ImageSmallSize = string.Format("{0}/{1}/{2}", Contains.PostFolder, str, str3); } int?menuId = post.MenuId; int i = 0; if ((menuId.GetValueOrDefault() > i ? menuId.HasValue : false)) { IMenuLinkService menuLinkService = this._menuLinkService; menuId = post.MenuId; MenuLink byId = menuLinkService.GetById(menuId.Value); post.VirtualCatUrl = byId.VirtualSeoUrl; post.VirtualCategoryId = byId.VirtualId; } HttpFileCollectionBase files = base.Request.Files; List <GalleryImage> galleryImages = null; if (files.Count > 0) { galleryImages = new List <GalleryImage>(); int count = files.Count - 1; int num = 0; string[] allKeys = files.AllKeys; for (i = 0; i < (int)allKeys.Length; i++) { string str4 = allKeys[i]; if (num <= count) { if (!str4.Equals("Image")) { HttpPostedFileBase item = files[num]; if (item.ContentLength > 0) { GalleryImageViewModel galleryImageViewModel = new GalleryImageViewModel() { PostId = post.Id }; string str5 = string.Format("{0}-{1}", str, App.Utils.Utils.GetTime()); string str6 = string.Format("{0}-{1}", str, App.Utils.Utils.GetTime()); this._imagePlugin.CropAndResizeImage(item, string.Format("{0}/{1}/", Contains.PostFolder, str), str5, new int?(ImageSize.WithOrignalSize), new int?(ImageSize.HeighthOrignalSize), false); this._imagePlugin.CropAndResizeImage(item, string.Format("{0}/{1}/", Contains.PostFolder, str), str6, new int?(ImageSize.WithThumbnailSize), new int?(ImageSize.HeightThumbnailSize), false); galleryImageViewModel.ImageThumbnail = string.Format("{0}/{1}/{2}", Contains.PostFolder, str, str6); galleryImageViewModel.ImagePath = string.Format("{0}/{1}/{2}", Contains.PostFolder, str, str5); galleryImageViewModel.OrderDisplay = num; galleryImageViewModel.Status = 1; galleryImageViewModel.Title = post.Title; galleryImages.Add(Mapper.Map <GalleryImage>(galleryImageViewModel)); } num++; } else { num++; } } } } Post post1 = Mapper.Map <PostViewModel, Post>(post); post1.GalleryImages = galleryImages; this._postService.Create(post1); return(base.RedirectToAction("PostManagement")); } } catch (Exception exception1) { Exception exception = exception1; ExtentionUtils.Log(string.Concat("Post.Create: ", exception.Message)); base.ModelState.AddModelError("", exception.Message); } return(base.View(post)); }
public MenuService(string connectionString) { _mLink = new MenuLink(connectionString); }
public async Task <int> CreateAsync(MenuLink model) { return(await repository.CreateAsync(model)); }
private MenuLinkList ConvertToExportModel(coreModels.MenuLinkList list) { var retVal = new MenuLinkList(); retVal.InjectFrom(list); foreach (var link in list.MenuLinks) { var addedLink = new MenuLink(); addedLink.InjectFrom(link); retVal.MenuLinks.Add(addedLink); } return retVal; }
void Update() { Vector2 direction = new Vector2(0, 0); bool inputPressed = false; if (Input.GetButtonDown("Vertical") || Input.GetButtonDown("Horizontal")) { direction = direction + getDirection(); enteringText = false; inputPressed = true; // Debug.Log("DirectoinV: " + direction); } if (inputPressed) { cm.SetDirection(direction); } selectedOption = cm.GetSelectedOption(); string clientState = ""; MenuLink ml = selectedOption.GetComponent <MenuLink>(); if (ml != null) { clientState = ml.GetState().ToString(); } if (clientState == "inputfield") { inputField = ml.GetComponent <InputField>(); enteringText = true; inputField.enabled = true; inputField.ActivateInputField(); } else { enteringText = false; if (inputField != null) { inputField.enabled = false; } } if (!enteringText) { if (Input.GetButtonDown("Fire1")) { switch (clientState) { case "menu": menuHandler.EnterMenu(ml.GetMenuItem()); break; case "register": // SubmitAccount("UsernameRegister", "PasswordRegister", ml, true); var submitobj = GameObject.Find("Submit"); var accountHandler = submitobj.GetComponent <AccountHandler>(); accountHandler.SubmitAccount("UsernameRegister", "PasswordRegister", ml, true); break; case "login": // SubmitAccount("UsernameLogin", "PasswordLogin", ml, false); submitobj = GameObject.Find("Submit"); accountHandler = submitobj.GetComponent <AccountHandler>(); accountHandler.SubmitAccount("UsernameLogin", "PasswordLogin", ml, false); break; case "cancel": menuHandler.GoUpMenu(); break; default: break; } } if (Input.GetButtonDown("Fire2") && !(MenuPrefabHandler.statusBoxOpened || prefabHandler.ModalBoxHasBeenOpened())) { menuHandler.GoUpMenu(); } } direction = new Vector2(0, 0); }