From 4b79f94986d21ff9be6a2970225f141c42fbfd68 Mon Sep 17 00:00:00 2001 From: AnushaD Date: Thu, 17 Aug 2023 16:46:19 -0700 Subject: [PATCH 1/2] Made changes to Hire method in Organization.cs --- dotnet/MyOrganization/Organization.cs | 51 +++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dotnet/MyOrganization/Organization.cs b/dotnet/MyOrganization/Organization.cs index 7480481..a628277 100644 --- a/dotnet/MyOrganization/Organization.cs +++ b/dotnet/MyOrganization/Organization.cs @@ -10,6 +10,7 @@ internal abstract class Organization { private Position root; + private int employeeId = 1; public Organization() { root = CreateOrganization(); @@ -27,9 +28,59 @@ public Organization() public Position? Hire(Name person, string title) { //your code here + //Get employee position based on Title + Position? position = GetTitlePosition(title, root); + //Check if position is available. + if (position == null) + { + Console.WriteLine("Position is unavailable"); + return null; + } + + if (position != null) + { + //Check if existing employee + if (position.IsFilled()) + { + Employee? previousEmployee = position.GetEmployee(); + Console.WriteLine("Position is already occupied."); + return null; + } + else + { + //Create new hire + Employee newEmployee = new Employee(GetNewId(), person); + position.SetEmployee(newEmployee); + Console.WriteLine("New employee is hired."); + return position; + } + } + return null; + } + + private Position? GetTitlePosition(string title, Position currentPosition) + { + if (currentPosition.GetTitle() == title) + { + return currentPosition; + } + + foreach (Position pos in currentPosition.GetDirectReports()) + { + Position? position = GetTitlePosition(title, pos); + if (position != null) + { + return position; + } + } return null; } + private int GetNewId() + { + employeeId++; + return employeeId; + } override public string ToString() { return PrintOrganization(root, ""); From abba3974019a47c70847a39cdf4a87e405169abf Mon Sep 17 00:00:00 2001 From: AnushaD42 <142549806+AnushaD42@users.noreply.github.com> Date: Thu, 31 Aug 2023 16:26:58 -0700 Subject: [PATCH 2/2] Add or update the Azure App Service build and deployment workflow config --- .github/workflows/main_dotnet-myhome.yml | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/main_dotnet-myhome.yml diff --git a/.github/workflows/main_dotnet-myhome.yml b/.github/workflows/main_dotnet-myhome.yml new file mode 100644 index 0000000..0829d81 --- /dev/null +++ b/.github/workflows/main_dotnet-myhome.yml @@ -0,0 +1,57 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions + +name: Build and deploy ASP.Net Core app to Azure Web App - dotnet-myhome + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + include-prerelease: true + + - name: Build with dotnet + run: dotnet build --configuration Release + + - name: dotnet publish + run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp + + - name: Upload artifact for deployment job + uses: actions/upload-artifact@v2 + with: + name: .net-app + path: ${{env.DOTNET_ROOT}}/myapp + + deploy: + runs-on: windows-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: .net-app + + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: 'dotnet-myhome' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_B2F2E882FD3C4113947A86B8C05530B9 }} + package: .