public IActionResult GetDepartments() { List <DepartmentResponseDTO> DepartmentResponseDTO = new List <DepartmentResponseDTO>(); foreach (var item in _context.Departments) { DepartmentResponseDTO fooObject = new DepartmentResponseDTO() { Id = item.Id, Name = item.Name }; DepartmentResponseDTO.Add(fooObject); } APIResult apiResult = APIResultFactory.Build(true, StatusCodes.Status200OK, ErrorMessageEnum.None, payload: DepartmentResponseDTO); return(Ok(apiResult)); }
public StudentWithDepartmantResponseDTO GetStudentInfoFromDepartmentByUuid(string uuid) { Student foundStudent = this.FindOneByUuidOrThrow(uuid); Student authStudent = this.FindOneByUuidOrThrow(new UserPrincipal(this._httpContextAccessor.HttpContext).uuid); if (!authStudent.departmentUuid.Equals(foundStudent.departmentUuid)) { throw new EntityNotFoundException("No student with that uuid on the same department as you!", GeneralConsts.MICROSERVICE_NAME); } DepartmentResponseDTO department = this._httpClientService.SendRequest <DepartmentResponseDTO>(HttpMethod.Get, "http://localhost:40007/api/departments/" + authStudent.departmentUuid, new UserPrincipal(this._httpContextAccessor.HttpContext).token).Result; StudentWithDepartmantResponseDTO response = this._autoMapper.Map <StudentWithDepartmantResponseDTO>(foundStudent); response.departmentName = department.name; return(response); }