From f3c592cd6f9e90116a297f9c77eee69651742f9c Mon Sep 17 00:00:00 2001 From: Julian Schmidt Date: Mon, 4 Sep 2023 16:08:49 +0200 Subject: [PATCH] feat: remove Functions Test --- .../workflows/main_versteigerungbackend.yml | 44 ------------ .../Functions/AuctionFunction.cs | 67 ------------------- 2 files changed, 111 deletions(-) delete mode 100644 .github/workflows/main_versteigerungbackend.yml delete mode 100644 backend/Versteigerungs-App/Versteigerungs-App/Functions/AuctionFunction.cs diff --git a/.github/workflows/main_versteigerungbackend.yml b/.github/workflows/main_versteigerungbackend.yml deleted file mode 100644 index 07f3b76..0000000 --- a/.github/workflows/main_versteigerungbackend.yml +++ /dev/null @@ -1,44 +0,0 @@ -# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action -# More GitHub Actions for Azure: https://github.com/Azure/actions - -name: Build and deploy dotnet core app to Azure Function App - versteigerungBackend - -on: - push: - branches: - - main - paths: - - 'backend/**' - workflow_dispatch: - -env: - AZURE_FUNCTIONAPP_PACKAGE_PATH: './backend/Versteigerungs-App/Versteigerungs-App' # set this to the path to your web app project, defaults to the repository root - DOTNET_VERSION: '7.0.x' # set this to the dotnet version to use - -jobs: - build-and-deploy: - runs-on: windows-latest - steps: - - name: 'Checkout GitHub Action' - uses: actions/checkout@v2 - - - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment - uses: actions/setup-dotnet@v1 - with: - dotnet-version: ${{ env.DOTNET_VERSION }} - - - name: 'Resolve Project Dependencies Using Dotnet' - shell: pwsh - run: | - pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' - dotnet build --configuration Release --output ./output - popd - - - name: 'Run Azure Functions Action' - uses: Azure/functions-action@v1 - id: fa - with: - app-name: 'versteigerungBackend' - slot-name: 'Production' - package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/output' - publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_9301EC6F33264B31B31724B5C159F3CB }} diff --git a/backend/Versteigerungs-App/Versteigerungs-App/Functions/AuctionFunction.cs b/backend/Versteigerungs-App/Versteigerungs-App/Functions/AuctionFunction.cs deleted file mode 100644 index 47e6214..0000000 --- a/backend/Versteigerungs-App/Versteigerungs-App/Functions/AuctionFunction.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System.Text.Json; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Azure.WebJobs; -using Microsoft.Azure.WebJobs.Extensions.Http; -using Versteigerungs_App.Models; -using Versteigerungs_App.Services; - -public class AuctionFunction -{ - - private readonly IAuctionService _auctionService; - private readonly ILogger _logger; - - public AuctionFunction(IAuctionService auctionService, ILogger logger) - { - _auctionService = auctionService; - _logger = logger; - } - - [Authorize] - [FunctionName("SetAuctionTimes")] - public async Task SetAuctionTimes( - [HttpTrigger(AuthorizationLevel.Function, "patch", Route = "auction/times")] HttpRequest req) - { - try - { - // Validate admin access here (you'll need to implement this logic) - // if (!User.GetUser().IsAdmin()) - // { - // return new UnauthorizedResult(); - // } - - var requestBody = await new StreamReader(req.Body).ReadToEndAsync(); - var auctionTimes = JsonSerializer.Deserialize(requestBody) ?? throw new ArgumentException("Invalid request body."); - - var success = await _auctionService.SetAuctionTimes(auctionTimes.StartTime, auctionTimes.EndTime); - if (success) - { - return new OkObjectResult("Auction times set successfully."); - } - - return new BadRequestObjectResult("Auction times could not be set."); - } - catch (Exception ex) - { - _logger.LogError(ex, "An error occurred while processing the request."); - return new StatusCodeResult(500); - } - } - - [FunctionName("GetAuctionTimes")] - public async Task GetAuctionTimes( - [HttpTrigger(AuthorizationLevel.Function, "get", Route = "auction/times")] HttpRequest req) - { - try - { - var auctionTimes = await _auctionService.GetAuctionTimes(); - return new OkObjectResult(auctionTimes); - } - catch (Exception ex) - { - _logger.LogError(ex, "An error occurred while processing the request."); - return new StatusCodeResult(500); - } - } -}