Exemplo n.º 1
0
        public SelectList GetSortDropdown()
        {
            List <ModuleRPS> moduleList =
                ModuleRPS.GetListAll()
                .Where
                    (item => item.ParentId == ParentId)
                .ToList();
            List <SelectListItem> list = moduleList.Select(
                x => new SelectListItem
            {
                Text     = Name == x.Name ? string.Format("Current") : string.Format("{0}", x.Name),
                Value    = x.SortId.ToString(),
                Selected = x.SortId == SortId ? true : false
            }
                ).ToList();

            list = list.OrderBy(x => x.Value).ToList();
            //kalau module tu last,
            //tak payah letak bottom
            if (SortId == 0)
            {
                int maxVal = moduleList.Max(x => x.SortId) + 1;
                list.Insert(list.Count, new SelectListItem {
                    Text = string.Format("New"), Value = (maxVal).ToString()
                });
            }

            SelectList parentList = new SelectList(list, "Value", "Text");

            return(parentList);
        }
Exemplo n.º 2
0
 public static ModuleRPS GetModule(int id)
 {
     if (id > 0)
     {
         List <ModuleRPS> modules = GetListAll().ToList();
         ModuleRPS        module  = modules.Where(item => item.ID == id).FirstOrDefault();
         return(module);
     }
     else
     {
         ModuleRPS module = new ModuleRPS
         {
             ID     = 0,
             SortId = 0
         };
         return(module);
     }
 }
Exemplo n.º 3
0
        public SelectList GetParentDropdown()
        {
            List <ModuleRPS> moduleList = ModuleRPS.GetListAll().ToList();

            //remove self from list of dropdown
            //(prevent selecting self as parent)
            moduleList = RemoveFromList(moduleList);

            List <SelectListItem> list = moduleList.Select(
                x => new SelectListItem
            {
                Text     = x.Name,
                Value    = x.ID.ToString(),
                Selected = x.ParentId == ParentId ? true : false
            }
                ).ToList();

            list.Insert(0, new SelectListItem {
                Text = "Root", Value = "0"
            });
            SelectList parentList = new SelectList(list, "Value", "Text");

            return(parentList);
        }
Exemplo n.º 4
0
 public static ModuleTree BuildTreeByUsername()
 {
     //get modules selected by user
     return(BuildTree(ModuleRPS.GetListByUsername()));
 }
Exemplo n.º 5
0
 public static ModuleTree BuildTree()
 {
     //get all active modules
     return(BuildTree(ModuleRPS.GetListAll()));
 }
Exemplo n.º 6
0
 public static List <JsTreeModel> BuildTree()
 {
     return(BuildTree(ModuleRPS.GetListByUsername()));
 }