public async Task <IActionResult> GetOrganizationAsync() { var requesttDepartments = new ListDepartmentsRequest(); var responsetDepartments = await _organizationClient.ListDepartmentsAsync(requesttDepartments); var requesttJobs = new ListJobsRequest(); var responsetJobs = await _organizationClient.ListJobsAsync(requesttJobs); var result = new GetOrganizationOutput { Departments = responsetDepartments.Items .Select(x => new DepartmentSummary { Id = x.Id, Name = x.Name, ParentId = x.ParentId, }) .ToList(), Jobs = responsetJobs.Items .Select(x => new JobSummary { Id = x.Id, Title = x.Title, }) .ToList(), }; return(Ok(result)); }
public override async Task <ListDepartmentsResponse> ListDepartments(ListDepartmentsRequest request, ServerCallContext context) { var departments = await _organizationApp.GetDepartmentsAsync(); var items = departments.Select(x => new ListDepartmentsResponse.Types.Department { Id = x.Id, Name = x.Name, ParentId = x.ParentId, }); var result = new ListDepartmentsResponse(); result.Items.AddRange(items); return(result); }
public ListDepartmentsResponse ListDepartments(ListDepartmentsRequest request) { Platform.CheckForNullReference(request, "request"); var where = new DepartmentSearchCriteria(); where.Id.SortAsc(0); var broker = PersistenceContext.GetBroker <IDepartmentBroker>(); var items = broker.Find(where, request.Page); var assembler = new DepartmentAssembler(); return(new ListDepartmentsResponse( CollectionUtils.Map(items, (Department item) => assembler.CreateSummary(item, PersistenceContext)) )); }