/// <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>()); }
public IActionResult UpdateDepartment(DeptDto updated) { if (updated != null && updated.Id != 0) { var result = _deptLogic.UpdateDept(updated); return(Ok(DtoTransfer.ConvertDeptToDto(result))); } return(BadRequest()); }
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()); }
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()); }
/// <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>()); }
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()); }
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)); }
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)); }
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); }
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); }
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)); }