Ejemplo n.º 1
0
 public void CreateNewDepartment(EditDepartmentModel model)
 {
     var department = new Department();
     department.Name = model.FormData.Name;
     department.Unit = NpcContext.CurrentUser.Unit;
     if (model.ParentId.HasValue)
         department.Parent = _departmentRepository.Find(model.ParentId.Value);
     department.RecordDescription.CreateBy(NpcContext.CurrentUser);
     _departmentRepository.Save(department);
 }
Ejemplo n.º 2
0
        private DepartmentTreeModelComponent ConvertDepartmentToModel(Department department, bool isNeedSub)
        {
            var model = new DepartmentTreeModelComponent()
            {
                Id = department.Id,
                Name = department.Name,
                IconCls = ApplicationConst.TreeLeafCls,
            };
            var childrens = _departmentRepository.GetSubDepartment(NpcContext.CurrentUser.Unit.Id, department.Id).ToList();
            if (childrens.Any())
            {
                if (isNeedSub)
                {

                    childrens.ForEach(o => model.Childrens.Add(ConvertDepartmentToModel(o, true)));
                }
                model.IconCls = ApplicationConst.TreeParentNode;
                model.State = isNeedSub ? "open" : "closed";
            }

            return model;
        }
Ejemplo n.º 3
0
 private static SelectUserOptionsComponent ConvertDepartment2SelectUserOptionsRow(Department department)
 {
     return new SelectUserOptionsComponent()
     {
         Id = department.Id,
         Name = department.Name,
         NodeType = 1,
         IconCls = ApplicationConst.TreeParentNode
     };
 }