public async Task <ActionResult> Update(Guid id) { var model = new NavNodeUpdateModel(); var iquery = await _navNodeService.GetByIdAsync(id); if (iquery != null) { model = new NavNodeUpdateModel { Id = iquery.Id, Name = iquery.Name, Areas = iquery.Areas, Controller = iquery.Controller, Action = iquery.Action, Params = iquery.Params, ModeAction = CommonValues.Action.Update }; StringBuilder _display = new StringBuilder(); if (!string.IsNullOrEmpty(iquery.Areas)) { _display.Append(string.Concat("/", iquery.Areas)); } if (!string.IsNullOrEmpty(iquery.Controller)) { _display.Append(string.Concat("/", iquery.Controller)); } if (!string.IsNullOrEmpty(iquery.Action)) { _display.Append(string.Concat("/", iquery.Action)); } if (!string.IsNullOrEmpty(iquery.Params)) { _display.Append(string.Concat("?", iquery.Params)); } model.Link = _display.ToString(); } return(PartialView(model)); }
public async Task <ActionResult> Update(Guid id) { var model = new MenuUpdateModel(); var iquery = await _menuService.GetByIdAsync(id); if (iquery != null) { var lstMenu = _menuService.GetAllRecursive(); var roles = _menuService.GetAllRole(); model = new MenuUpdateModel { Id = iquery.Id, ParentId = iquery.ParentId, Layout = iquery.Layout, Status = iquery.Status, TypeModule = iquery.TypeModule, Name = iquery.Name, Code = iquery.Code, Target = iquery.Target, NavNodeId = iquery.NavNodeId, Icon = iquery.Icon, Order = iquery.Order, GroupOrUsers = iquery.GroupOrUsers, Action = Common.CommonValues.Action.Update, ListRole = roles.Select(x => new SelectListItem { Text = x.Name, Value = x.ID.ToString(), Selected = !string.IsNullOrEmpty(iquery.Roles) && iquery.Roles.Contains(x.ID.ToString()) ? true : false }), LstMenu = lstMenu .Select(x => new SelectListItem { Text = x.Name, Value = x.Id.ToString() }) }; List <SelectListItem> listGroupOrUser = new List <SelectListItem>(); if (!string.IsNullOrEmpty(model.GroupOrUsers)) { var groupOrUsers = model.GroupOrUsers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (var item in groupOrUsers) { var listItem = new SelectListItem(); if (item.Contains("_User")) { var userId = new Guid(item.Replace("_User", "")); var user = _userServices.GetById(userId); listItem.Text = user.FullName + " (" + user.UserName + ")"; listItem.Value = item; } if (item.Contains("_Group")) { var groupId = new Guid(item.Replace("_Group", "")); var group = _groupServices.GetById(groupId); listItem.Text = group.Name; listItem.Value = item; } listGroupOrUser.Add(listItem); } } model.ListGroupOrUser = listGroupOrUser; if (iquery.NavNodeId.HasValue) { var iqueryNav = await _navNodeService.GetByIdAsync(iquery.NavNodeId.Value); if (iqueryNav != null) { StringBuilder _display = new StringBuilder(); if (!string.IsNullOrEmpty(iqueryNav.Areas)) { _display.Append(string.Concat("/", iqueryNav.Areas)); } if (!string.IsNullOrEmpty(iqueryNav.Controller)) { _display.Append(string.Concat("/", iqueryNav.Controller)); } if (!string.IsNullOrEmpty(iqueryNav.Action)) { _display.Append(string.Concat("/", iqueryNav.Action)); } if (!string.IsNullOrEmpty(iqueryNav.Params)) { _display.Append(string.Concat("?", iqueryNav.Params)); } model.Link = _display.ToString(); model.navAutocomplete = iqueryNav.Name; } } } return(View(model)); }