Exemplo n.º 1
0
        /// <summary>
        /// 新增系别
        /// </summary>
        /// <param name="deptDto"></param>
        /// <returns></returns>
        public async Task <DeptDto> InsertDept(DeptDto deptDto)
        {
            // deptDto.CreateTime = TimeUtil.GetTimeStampNow();
            var dept = await _deptRepository.InsertNowAsync(deptDto.Adapt <TbDept>());

            return(dept.Entity.Adapt <DeptDto>());
        }
Exemplo n.º 2
0
        public IActionResult UpdateDepartment(DeptDto updated)
        {
            if (updated != null && updated.Id != 0)
            {
                var result = _deptLogic.UpdateDept(updated);
                return(Ok(DtoTransfer.ConvertDeptToDto(result)));
            }

            return(BadRequest());
        }
Exemplo n.º 3
0
        public IActionResult AddNewDepartment(DeptDto newDept)
        {
            if (newDept != null && newDept.Id == 0)
            {
                var added = _deptLogic.UpdateDept(newDept, OperationTypeEnum.Add);
                return(Ok(DtoTransfer.ConvertDeptToDto(added)));
            }

            return(BadRequest());
        }
Exemplo n.º 4
0
        public IActionResult GetDept(DeptDto filter, int pageIndex = 1, int pageSize = 20)
        {
            var depts = _deptLogic.GetDepts(filter, pageIndex, pageSize);

            if (depts != null && depts.Count > 0)
            {
                return(Ok(depts));
            }

            return(NotFound());
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新系别
        /// </summary>
        /// <param name="deptDto"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public async Task <DeptDto> UpdateDept(DeptDto deptDto)
        {
            var dept = await _deptRepository.FirstOrDefaultAsync(x => x.Id == deptDto.Id);

            if (dept == null)
            {
                throw Oops.Oh(DeptErrorCodes.d1301);
            }
            var changeDept = deptDto.Adapt(dept);
            await changeDept.UpdateExcludeAsync(u => u.CreateTime);

            return(changeDept.Adapt <DeptDto>());
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Index()
        {
            var deptRoot = new DeptDto
            {
                DeptID   = 0,
                DeptName = "全部",
                ParentID = -1
            };
            var deptList = await _deptService.GetListAsnyc();

            deptList.Add(deptRoot);
            ViewBag.deptList = JsonConvert.SerializeObject(deptList);
            return(View());
        }
Exemplo n.º 7
0
 public ICollection <Department> GetDepts(DeptDto filters, int pageIndex = 1, int pageSize = 20)
 {
     return(_OrgManager.GetDepartments(new Department
     {
         Code = filters.Code,
         CompanyId = filters.CompanyId,
         DirectorId = filters.DirectorId,
         EmployeeIds = string.Join(',', filters.EmployeeIds),
         Name = filters.Name,
         Location = filters.Location,
         ParentId = filters.ParentId,
         Id = filters.Id,
         Status = Enum.Parse <OrganizationStatusEnum>(filters.Status),
     }, pageIndex, pageSize));
 }
Exemplo n.º 8
0
        public async Task <IActionResult> Form(DeptDto dept, int id = 0)
        {
            var model = _userService.Init(id).Data;

            if (model.UserID == 0)
            {
                model.DeptID   = dept.DeptID;
                model.DeptName = dept.DeptID == 0 ? "" : dept.DeptName;
            }
            if (model.Photo != null)
            {
                this.ViewBag.avatar = "data:image/png;base64," + Convert.ToBase64String(model.Photo);
            }
            ViewBag.deptList = JsonConvert.SerializeObject(await _deptService.GetListAsnyc());
            ViewBag.roleList = await _roleService.GetListAsnyc();

            return(View(model));
        }
Exemplo n.º 9
0
        public Department UpdateDept(DeptDto dept, OperationTypeEnum operationType = OperationTypeEnum.Update)
        {
            if (dept != null)
            {
                return(_OrgManager.UpdateDepartment(new Department
                {
                    Id = dept.Id,
                    Status = Enum.Parse <OrganizationStatusEnum>(dept.Status),
                    CompanyId = dept.CompanyId,
                    Description = dept.Description,
                    DirectorId = dept.DirectorId,
                    EmployeeIds = string.Join(',', dept.EmployeeIds),
                    Location = dept.Location,
                    Name = dept.Name,
                    ParentId = dept.ParentId,
                }, operationType: operationType));
            }

            return(null);
        }
Exemplo n.º 10
0
        public static DeptDto ToDeptDto(SysDept sysDept)
        {
            var dto = new DeptDto
            {
                Fullname   = sysDept.Fullname,
                Simplename = sysDept.Simplename,
                CreateBy   = sysDept.CreateBy?.ToString() ?? string.Empty,
                CreateTime = sysDept.CreateTime?.ToString() ?? string.Empty,
                Id         = sysDept.Id.ToString(),
                ModifyBy   = sysDept.ModifyBy?.ToString() ?? string.Empty,
                ModifyTime = sysDept.ModifyTime?.ToString() ?? string.Empty,
                Num        = sysDept.Num ?? 1,
                Pid        = sysDept.Pid.Value().ToString(),
                Pids       = sysDept.Pids,
                Tips       = sysDept.Tips,
                Version    = sysDept.Version?.ToString() ?? "1",
                Children   = new List <DeptDto>()
            };

            return(dto);
        }
Exemplo n.º 11
0
 public IActionResult Form(DeptDto model)
 {
     _deptService.Data = model;
     return(SuccessJsonResult());
 }
 /// <summary>
 /// 数据插入或更新
 /// </summary>
 /// <param name="dto"></param>
 /// <returns></returns>
 public DeptDto InsertOrUpdate(DeptDto dto)
 {
     return(_repository.InsertOrUpdate(dto));
 }