コード例 #1
0
        public async Task <IActionResult> Form(int id = 0)
        {
            var model = _deptService.Init(id).Data;
            var list  = await _deptService.GetListAsnyc();

            if (id != 0)
            {
                var listRemove = new List <DeptDto>();
                _deptService.GetDeptByParentId(listRemove, id);
                //removeChild
                list.RemoveAll(item => listRemove.Any(p => p.DeptID == item.DeptID));
                //removeSelf
                list.RemoveAll(p => p.DeptID == model.DeptID);
            }
            ViewBag.deptList = JsonConvert.SerializeObject(list);
            return(View(model));
        }