public async Task CrateData(Guid employeeId, Guid roleId) { using IEmployeesOrRoleService employeesOrRoleService = new EmployeesOrRoleService(); await employeesOrRoleService.CreateAsync(new EmployeeOrRole() { UserId = employeeId, RoleId = roleId }); }
public async Task <List <EmployeeOrRoleDto> > GetAllEmployeesOrRole() { using IEmployeesOrRoleService employeesOrRoleService = new EmployeesOrRoleService(); return(await employeesOrRoleService.GetAllAsync().Select(i => new EmployeeOrRoleDto() { Id = i.Id, EmployeesId = i.UserId, RoleId = i.RoleId }).ToListAsync()); }
/// <summary> /// 删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task RemoveRmpOrRole(Guid id) { using IEmployeesOrRoleService employeesOrRoleService = new EmployeesOrRoleService(); if (await employeesOrRoleService.GetAllAsync().AnyAsync(i => i.Id == id)) { var employeeOrRole = employeesOrRoleService.GetAllAsync().FirstOrDefault(i => i.Id == id); if (employeeOrRole != null) { await employeesOrRoleService.RemoveAsync(id); } } }
/// <summary> /// 修改 /// </summary> /// <param name="id"></param> /// <param name="userId"></param> /// <param name="roleId"></param> /// <returns></returns> public async Task EditEmpOrRole(Guid id, Guid userId, Guid roleId) { using IEmployeesOrRoleService employeesOrRoleService = new EmployeesOrRoleService(); if (await employeesOrRoleService.GetAllAsync().AnyAsync(i => i.Id == id)) { var employeeOrRole = employeesOrRoleService.GetAllAsync().FirstOrDefault(i => i.Id == id); if (employeeOrRole != null) { employeeOrRole.UserId = userId; employeeOrRole.RoleId = roleId; } await employeesOrRoleService.EditAsync(employeeOrRole); } }