public ActionResult Create() { var model = new MenuLinkViewModel(); //Add locales to model AddLocales(_languageService, model.Locales); return(base.View(model)); }
public ActionResult Create() { var model = new MenuLinkViewModel { OrderDisplay = 1, Status = 1 }; //Add locales to model AddLocales(_languageService, model.Locales); return(View(model)); }
private void ImageHandler(MenuLinkViewModel model) { var isPng = _settingService.GetSetting("Menu.pngFormat", 0); var folderName = CommonHelper.FolderName(model.MenuName); if (model.ImageBigSizeFile != null && model.ImageBigSizeFile.ContentLength > 0) { var fileName = Path.GetFileNameWithoutExtension(model.ImageBigSizeFile.FileName); var fileExtension = Path.GetExtension(model.ImageBigSizeFile.FileName); var fileNameFormat = fileName.FileNameFormat(fileExtension); var sizeWidthBg = _settingService.GetSetting("Menu.WidthBigSize", ImageSize.WidthDefaultSize); var sizeHeighthBg = _settingService.GetSetting("Menu.HeightBigSize", ImageSize.HeightDefaultSize); _imageService.CropAndResizeImage(model.ImageBigSizeFile, $"{Constant.MenuFolder}{folderName}/", fileNameFormat, sizeWidthBg, sizeHeighthBg, isPng != 0); model.ImageBigSize = $"{Constant.MenuFolder}{folderName}/{fileNameFormat}"; } if (model.ImageMediumSizeFile != null && model.ImageMediumSizeFile.ContentLength > 0) { var fileName = Path.GetFileNameWithoutExtension(model.ImageMediumSizeFile.FileName); var fileExtension = Path.GetExtension(model.ImageMediumSizeFile.FileName); var fileNameFormat = fileName.FileNameFormat(fileExtension); var sizeWidthMd = _settingService.GetSetting("Menu.WidthMediumSize", ImageSize.WidthDefaultSize); var sizeHeighthMd = _settingService.GetSetting("Menu.HeightMediumSize", ImageSize.HeightDefaultSize); _imageService.CropAndResizeImage(model.ImageMediumSizeFile, $"{Constant.MenuFolder}{folderName}/", fileNameFormat, sizeWidthMd, sizeHeighthMd, isPng != 0); model.ImageMediumSize = $"{Constant.MenuFolder}{folderName}/{fileNameFormat}"; } if (model.ImageSmallSizeFile != null && model.ImageSmallSizeFile.ContentLength > 0) { var fileName = Path.GetFileNameWithoutExtension(model.ImageSmallSizeFile.FileName); var fileExtension = Path.GetExtension(model.ImageSmallSizeFile.FileName); var fileNameFormat = fileName.FileNameFormat(fileExtension); var sizeWidthSm = _settingService.GetSetting("Menu.WidthSmallSize", ImageSize.WidthDefaultSize); var sizeHeighthSm = _settingService.GetSetting("Menu.HeightSmallSize", ImageSize.HeightDefaultSize); _imageService.CropAndResizeImage(model.ImageSmallSizeFile, $"{Constant.MenuFolder}{folderName}/", fileNameFormat, sizeWidthSm, sizeHeighthSm, isPng != 0); model.ImageSmallSize = $"{Constant.MenuFolder}{folderName}/{fileNameFormat}"; } }
public ActionResult Edit(int Id) { MenuLinkViewModel modelMap = Mapper.Map <MenuLink, MenuLinkViewModel>(this._menuLinkService.GetById(Id)); //Add Locales to model AddLocales(_languageService, modelMap.Locales, (locale, languageId) => { locale.Id = modelMap.Id; locale.LocalesId = modelMap.Id; locale.MenuName = modelMap.GetLocalized(x => x.MenuName, Id, languageId, false, false); locale.MetaTitle = modelMap.GetLocalized(x => x.MetaTitle, Id, languageId, false, false); locale.MetaKeywords = modelMap.GetLocalized(x => x.MetaKeywords, Id, languageId, false, false); locale.MetaDescription = modelMap.GetLocalized(x => x.MetaDescription, Id, languageId, false, false); locale.SeoUrl = modelMap.GetLocalized(x => x.SeoUrl, Id, languageId, false, false); }); return(base.View(modelMap)); }
public static MenuLinkViewModel ToModel(this MenuLink model, MenuLinkViewModel destination) { if (model == null) { throw new ArgumentNullException("MenuLink"); } if (destination == null) { throw new ArgumentNullException("MenuLinkViewModel"); } destination.Id = model.Id; destination.ParentId = model.ParentId; destination.Status = model.Status; destination.TypeMenu = model.TypeMenu; destination.PositionMenuLinks = model.PositionMenuLinks; destination.MenuName = model.MenuName; destination.SeoUrl = model.SeoUrl; destination.OrderDisplay = model.OrderDisplay; destination.ImageBigSize = model.ImageBigSize; destination.ImageMediumSize = model.ImageMediumSize; destination.ImageSmallSize = model.ImageSmallSize; destination.CurrentVirtualId = model.CurrentVirtualId; destination.VirtualId = model.VirtualId; destination.TemplateType = model.TemplateType; destination.MetaTitle = model.GetLocalized(x => x.MetaTitle, model.Id); destination.MetaKeywords = model.GetLocalized(x => x.MetaKeywords, model.Id); destination.MetaDescription = model.GetLocalized(x => x.MetaDescription, model.Id); destination.Language = model.Language; destination.SourceLink = model.SourceLink; destination.VirtualSeoUrl = model.VirtualSeoUrl; destination.DisplayOnHomePage = model.DisplayOnHomePage; destination.DisplayOnMenu = model.DisplayOnMenu; destination.DisplayOnSearch = model.DisplayOnSearch; destination.GenericControls = model.GenericControls; return(destination); }
protected override void OnActionExecuted(ActionExecutedContext filterContext) { if (filterContext.RouteData.Values["action"].Equals("create")) { IEnumerable <MenuLink> lstMenuLink = _menuLinkService.GetAll(); MenuLinkViewModel menuLinkViewModel = new MenuLinkViewModel(); IEnumerable <MenuLinkViewModel> model = lstMenuLink.Select(m => { return(m.ToModel(menuLinkViewModel)); }); ((dynamic)base.ViewBag).MenuLink = model; } if (filterContext.RouteData.Values["action"].Equals("edit")) { int id = int.Parse(filterContext.RouteData.Values["id"].ToString()); IEnumerable <MenuLink> lstMenuLink = _menuLinkService.GetAll(); IEnumerable <MenuLinkViewModel> model = from x in lstMenuLink select new MenuLinkViewModel() { Id = x.Id, ParentId = x.ParentId, Status = x.Status, TypeMenu = x.TypeMenu, Position = x.Position, MenuName = x.MenuName, VirtualId = x.VirtualId, Selected = x.SelectedMenu(id) }; ((dynamic)base.ViewBag).GCMenuLink = model; } }
public ActionResult Create(MenuLinkViewModel model, string returnUrl) { ActionResult action; try { if (!ModelState.IsValid) { var messages = string.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); ModelState.AddModelError("", messages); return(View(model)); } var menuName = model.MenuName.NonAccent(); var menuExsist = _menuLinkService.GetListSeoUrl(menuName); model.SeoUrl = model.MenuName.NonAccent(); if (menuExsist.Any(x => x.Id != model.Id)) { var menuLinkViewModel = model; var seoUrl = menuLinkViewModel.SeoUrl; var num = menuExsist.Count(); menuLinkViewModel.SeoUrl = string.Concat(seoUrl, "-", num.ToString()); } ImageHandler(model); var guid = Guid.NewGuid().ToString(); if (model.ParentId.HasValue) { model.CurrentVirtualId = guid; var byId = _menuLinkService.GetMenu(model.ParentId.Value); model.VirtualId = $"{byId.VirtualId}/{guid}"; model.VirtualSeoUrl = $"{byId.SeoUrl}/{model.SeoUrl}"; } else { model.VirtualId = guid; model.CurrentVirtualId = guid; } var modelMap = Mapper.Map <MenuLinkViewModel, MenuLink>(model); _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); } Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.MenuLink))); if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\")) { action = RedirectToAction("Index"); } else { action = Redirect(returnUrl); } } catch (Exception ex) { LogText.Log(string.Concat("MenuLink.Create: ", ex.Message)); return(View(model)); } return(action); }
public ActionResult Edit(MenuLinkViewModel model, string returnUrl) { ActionResult action; try { if (!ModelState.IsValid) { var messages = string.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); ModelState.AddModelError("", messages); return(View(model)); } var menuExsist = _menuLinkService.GetMenu(model.Id); var menuName = model.MenuName.NonAccent(); var bySeoUrl = _menuLinkService.GetListSeoUrl(menuName); model.SeoUrl = model.MenuName.NonAccent(); if (bySeoUrl.Any(x => x.Id != model.Id)) { var menuLinkViewModel = model; var seoUrl = menuLinkViewModel.SeoUrl; var num = bySeoUrl.Count(); menuLinkViewModel.SeoUrl = string.Concat(seoUrl, "-", num.ToString()); } ImageHandler(model); var parentId = model.ParentId; if (!parentId.HasValue) { model.ParentId = null; model.VirtualId = menuExsist.CurrentVirtualId; model.VirtualSeoUrl = null; } else { var byId1 = _menuLinkService.GetMenu(parentId.Value); model.VirtualId = $"{byId1.VirtualId}/{menuExsist.CurrentVirtualId}"; model.VirtualSeoUrl = $"{byId1.SeoUrl}/{model.SeoUrl}"; } //Get PositionMenuLink selected var positionMenuLinks = new List <Domain.Menus.PositionMenuLink>(); var positionIds = new List <int>(); var position = Request["Position"]; if (!string.IsNullOrEmpty(position)) { foreach (var item in position.Split(',').ToList()) { var positionId = int.Parse(item); positionIds.Add(positionId); positionMenuLinks.Add(_positionMenuLink.GetById(positionId, false)); } if (positionIds.IsAny()) { (from x in menuExsist.PositionMenuLinks where !positionIds.Contains(x.Id) select x).ToList() .ForEach(m => menuExsist.PositionMenuLinks.Remove(m) ); } } menuExsist.PositionMenuLinks = positionMenuLinks; var modelMap = Mapper.Map(model, menuExsist); _menuLinkService.Update(menuExsist); //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); } Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.UpdateSuccess, FormUI.MenuLink))); if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\")) { action = RedirectToAction("Index"); } else { action = Redirect(returnUrl); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); LogText.Log(string.Concat("MenuLink.Create: ", ex.Message)); return(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); }
public ActionResult Create(MenuLinkViewModel model, string returnUrl) { ActionResult action; try { if (!ModelState.IsValid) { var messages = String.Join(Environment.NewLine, ModelState.Values.SelectMany(v => v.Errors) .Select(v => v.ErrorMessage + " " + v.Exception)); ModelState.AddModelError("", messages); return(View(model)); } var menuName = model.MenuName.NonAccent(); var bySeoUrl = _menuLinkService.GetListSeoUrl(menuName); model.SeoUrl = model.MenuName.NonAccent(); if (bySeoUrl.Any(x => x.Id != model.Id)) { var menuLinkViewModel = model; var seoUrl = menuLinkViewModel.SeoUrl; var num = bySeoUrl.Count(); menuLinkViewModel.SeoUrl = string.Concat(seoUrl, "-", num.ToString()); } var folderName = Utils.FolderName(model.MenuName); if (model.ImageBigSizeFile != null && model.ImageBigSizeFile.ContentLength > 0) { var fileName = Path.GetFileNameWithoutExtension(model.ImageBigSizeFile.FileName); var fileExtension = Path.GetExtension(model.ImageBigSizeFile.FileName); var fileNameFormat = fileName.FileNameFormat(fileExtension); _imagePlugin.CropAndResizeImage(model.ImageBigSizeFile, $"{Contains.MenuFolder}{folderName}/", fileNameFormat, ImageSize.MenuWithBigSize, ImageSize.MenuHeightBigSize, true); model.ImageBigSize = $"{Contains.MenuFolder}{folderName}/{fileNameFormat}"; } if (model.ImageMediumSizeFile != null && model.ImageMediumSizeFile.ContentLength > 0) { var fileName = Path.GetFileNameWithoutExtension(model.ImageMediumSizeFile.FileName); var fileExtension = Path.GetExtension(model.ImageMediumSizeFile.FileName); var fileNameFormat = fileName.FileNameFormat(fileExtension); _imagePlugin.CropAndResizeImage(model.ImageMediumSizeFile, $"{Contains.MenuFolder}{folderName}/", fileNameFormat, ImageSize.MenuWithMediumSize, ImageSize.MenuHeightMediumSize, true); model.ImageMediumSize = $"{Contains.MenuFolder}{folderName}/{fileNameFormat}"; } if (model.ImageSmallSizeFile != null && model.ImageSmallSizeFile.ContentLength > 0) { var fileName = Path.GetFileNameWithoutExtension(model.ImageSmallSizeFile.FileName); var fileExtension = Path.GetExtension(model.ImageSmallSizeFile.FileName); var fileNameFormat = fileName.FileNameFormat(fileExtension); _imagePlugin.CropAndResizeImage(model.ImageSmallSizeFile, $"{Contains.MenuFolder}{folderName}/", fileNameFormat, ImageSize.MenuWithSmallSize, ImageSize.MenuHeightSmallSize, true); model.ImageSmallSize = $"{Contains.MenuFolder}{folderName}/{fileNameFormat}"; } var guid = Guid.NewGuid().ToString(); if (model.ParentId.HasValue) { model.CurrentVirtualId = guid; var byId = _menuLinkService.GetById(model.ParentId.Value); model.VirtualId = $"{byId.VirtualId}/{guid}"; model.VirtualSeoUrl = $"{byId.SeoUrl}/{model.SeoUrl}"; } else { model.VirtualId = guid; model.CurrentVirtualId = guid; } var modelMap = Mapper.Map <MenuLinkViewModel, MenuLink>(model); _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); } Response.Cookies.Add(new HttpCookie("system_message", string.Format(MessageUI.CreateSuccess, FormUI.MenuLink))); if (!Url.IsLocalUrl(returnUrl) || returnUrl.Length <= 1 || !returnUrl.StartsWith("/") || returnUrl.StartsWith("//") || returnUrl.StartsWith("/\\")) { action = RedirectToAction("Index"); } else { action = Redirect(returnUrl); } } catch (Exception ex) { ExtentionUtils.Log(string.Concat("MenuLink.Create: ", ex.Message)); return(View(model)); } return(action); }
public IActionResult GetMenuList() { var currentUser = HttpContext.User; string roleId = currentUser.Claims.FirstOrDefault(c => c.Type == "role_id").Value; int newRoleId = roleId != "" ? Convert.ToInt32(roleId) : 0; List <MenuLinkViewModel> menuLinkACList = new List <MenuLinkViewModel>(); var moduleLink = (from mstModule in _dbContext.ModuleMaster join linkModule in _dbContext.Link on mstModule.ModuleId equals linkModule.ModuleId join roleRights in _dbContext.RoleRight on linkModule.LinkId equals roleRights.LinkId where roleRights.RoleId == newRoleId && linkModule.IsActive == true && roleRights.IsView == true select new NavigationMenuViewModel { ViewIndex = Convert.ToInt32(mstModule.ViewIndex), IconName = mstModule.IconName, IsSinglePage = linkModule.IsSinglePage, ModuleId = mstModule.ModuleId, ModuleName = mstModule.ModuleName, ParentId = linkModule.ParentId, RouteLink = linkModule.RouteLink, LinkId = linkModule.LinkId, Title = linkModule.Title, IsAdd = roleRights.IsAdd, IsEdit = roleRights.IsEdit, IsDelete = roleRights.IsDelete, IsView = roleRights.IsView, IsChangeStatus = roleRights.IsChangeStatus, LinkViewIndex = linkModule.ViewIndex }).OrderBy(x => x.ViewIndex).ThenBy(x => x.LinkViewIndex).GroupBy(x => x.ModuleId).ToList(); foreach (var item in moduleLink) { foreach (var subItem in item) { if (menuLinkACList.Count(x => x.ModuleId == subItem.ModuleId) == 0) { MenuLinkViewModel menuLinkAC = new MenuLinkViewModel(); if (subItem.IsSinglePage && subItem.IsView) { menuLinkAC.IconName = subItem.IconName; menuLinkAC.RouteLink = subItem.RouteLink; menuLinkAC.IsAdd = subItem.IsAdd; menuLinkAC.IsEdit = subItem.IsEdit; menuLinkAC.IsDelete = subItem.IsDelete; menuLinkAC.IsView = subItem.IsView; menuLinkAC.IsChangeStatus = subItem.IsChangeStatus; menuLinkAC.Title = subItem.Title; menuLinkAC.Home = true; menuLinkAC.ModuleId = subItem.ModuleId; menuLinkACList.Add(menuLinkAC); } else if (subItem.IsView) { menuLinkAC.IconName = subItem.IconName; //menuLinkAC.RouteLink = subItem.RouteLink; menuLinkAC.Title = subItem.ModuleName; //menuLinkAC.IsAdd = subItem.IsAdd; //menuLinkAC.IsEdit = subItem.IsEdit; //menuLinkAC.IsDelete = subItem.IsDelete; //menuLinkAC.IsView = subItem.IsView; //menuLinkAC.IsChangeStatus = subItem.IsChangeStatus; menuLinkAC.Home = false; menuLinkAC.ModuleId = subItem.ModuleId; menuLinkAC.Children = new List <MenuLinkViewModel>(); List <Link> linkList = _dbContext.Link.Where(x => x.ModuleId == item.Key && x.IsActive == true).ToList(); foreach (var subLink in linkList) { var mstRoleRights = _dbContext.RoleRight.FirstOrDefault(x => x.IsView && x.LinkId == subLink.LinkId && x.RoleId == newRoleId); if (mstRoleRights != null) { MenuLinkViewModel newSubLink = new MenuLinkViewModel(); newSubLink = _mapper.Map <MenuLinkViewModel>(mstRoleRights); newSubLink.Title = subLink.Title; newSubLink.RouteLink = subLink.RouteLink; newSubLink.Home = false; menuLinkAC.Children.Add(newSubLink); } } menuLinkACList.Add(menuLinkAC); } } } } return(Ok(menuLinkACList)); }