Skip to content

Dev #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/dev_contactapplicationtest.yml
Original file line number Diff line number Diff line change
@@ -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 app to Azure Web App - ContactApplicationTest

on:
push:
branches:
- dev
workflow_dispatch:

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Setup MSBuild path
uses: microsoft/[email protected]

- name: Setup NuGet
uses: NuGet/[email protected]

- name: Restore NuGet packages
run: nuget restore

- name: Publish to folder
run: msbuild /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="\published\"

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: ASP-app
path: '/published/**'

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@v3
with:
name: ASP-app

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'ContactApplicationTest'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_AB7BFC6B72F94FA4A1860A5B28EDC4A0 }}
package: .
66 changes: 66 additions & 0 deletions .github/workflows/master_contactdatabase.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# 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 app to Azure Web App - ContactDatabase

on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Setup MSBuild path
uses: microsoft/[email protected]

- name: Setup NuGet
uses: NuGet/[email protected]

- name: Restore NuGet packages
run: nuget restore

- name: Publish to folder
run: msbuild /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="\published\"

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: ASP-app
path: '/published/**'

deploy:
runs-on: windows-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: ASP-app

- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_EE81D81FF43E46B7BCCB09C9132C6C74 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_362D8DE799534C58B9C8E5B27DED6E26 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_97C93876D5774F3C9119269003F3BD28 }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'ContactDatabase'
slot-name: 'Production'
package: .

24 changes: 18 additions & 6 deletions CRUD application 2.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\NUnit.4.1.0\build\NUnit.props" Condition="Exists('packages\NUnit.4.1.0\build\NUnit.props')" />
<Import Project="packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -45,10 +46,25 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="nunit.framework, Version=4.0.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>packages\NUnit.4.1.0\lib\net462\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="nunit.framework.legacy, Version=4.0.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>packages\NUnit.4.1.0\lib\net462\nunit.framework.legacy.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
Expand Down Expand Up @@ -111,11 +127,6 @@
<HintPath>packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform">
<HintPath>packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
Expand Down Expand Up @@ -215,11 +226,12 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
<Error Condition="!Exists('packages\NUnit.4.1.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\NUnit.4.1.0\build\NUnit.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target> -->
</Project>
</Project>
4 changes: 2 additions & 2 deletions CRUD application 2.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.33801.447
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CRUD application 2", "CRUD application 2.csproj", "{D44C1C21-0289-4DD0-B139-6825EE5C13B2}"
EndProject
Expand Down
52 changes: 45 additions & 7 deletions Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,51 @@ public class UserController : Controller
public ActionResult Index()
{
// Implement the Index method here
return View(userlist);
}

// GET: User/Details/5
public ActionResult Details(int id)
{
// Implement the details method here
var user = userlist.FirstOrDefault(u => u.Id == id);
if (user == null)
{
return HttpNotFound();
}
return View(user);
}

// GET: User/Create
public ActionResult Create()
{
//Implement the Create method here

return View();
}

// POST: User/Create
[HttpPost]
public ActionResult Create(User user)
{
// Implement the Create method (POST) here
userlist.Add(user);
return RedirectToAction("Index");
}

// GET: User/Edit/5
public ActionResult Edit(int id)
{
// This method is responsible for displaying the view to edit an existing user with the specified ID.
// It retrieves the user from the userlist based on the provided ID and passes it to the Edit view.
var user = userlist.FirstOrDefault(u => u.Id == id);
if (user == null)
{
return HttpNotFound();
}
return View(user);
}

// POST: User/Edit/5
[HttpPost]
public ActionResult Edit(int id, User user)
Expand All @@ -48,19 +65,40 @@ public ActionResult Edit(int id, User user)
// If successful, it redirects to the Index action to display the updated list of users.
// If no user is found with the provided ID, it returns a HttpNotFoundResult.
// If an error occurs during the process, it returns the Edit view to display any validation errors.
var existingUser = userlist.FirstOrDefault(u => u.Id == id);
if (existingUser == null)
{
return HttpNotFound();
}
existingUser.Name = user.Name;
existingUser.Email = user.Email;
return RedirectToAction("Index");
}

// GET: User/Delete/5
public ActionResult Delete(int id)
{
// Implement the Delete method here
var user = userlist.FirstOrDefault(u => u.Id == id);
if (user == null)
{
return HttpNotFound();
}
return View(user);
}

// POST: User/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
// Implement the Delete method (POST) here
var user = userlist.FirstOrDefault(u => u.Id == id);
if (user == null)
{
return HttpNotFound();
}
userlist.Remove(user);
return RedirectToAction("Index");
}
}
}
2 changes: 1 addition & 1 deletion Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
Expand Down
41 changes: 41 additions & 0 deletions deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"type": "Microsoft.Web/sites",
"apiVersion": "2021-02-01",
"name": "[parameters('appName')]",
"location": "[parameters('location')]",
"properties": {
"serverFarmId": null
}
},
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2021-02-01-preview",
"name": "[concat(parameters('appName'), '-sqlserver')]",
"location": "[parameters('location')]",
"properties": {
"administratorLogin": "[parameters('databaseUsername')]",
"administratorLoginPassword": "[parameters('databasePassword')]",
"version": "12.0"
}
},
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2021-02-01-preview",
"name": "[concat(parameters('appName'), '-database')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', concat(parameters('appName'), '-sqlserver'))]"
],
"properties": {
"collation": "SQL_Latin1_General_CP1_CI_AS",
"edition": "Basic",
"maxSizeBytes": "1073741824",
"requestedServiceObjectiveName": "Basic"
}
}
]
}
35 changes: 35 additions & 0 deletions deploy.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"parameters": {
"appName": {
"type": "string",
"metadata": {
"description": "ContactApplicationTest"
}
},
"location": {
"type": "string",
"metadata": {
"description": "The Azure region where the resources will be deployed."
},
"defaultValue": "[resourceGroup().location]"
},
"databaseName": {
"type": "string",
"metadata": {
"description": "The name of the Contact Database."
}
},
"databaseUsername": {
"type": "string",
"metadata": {
"description": "The username for the Contact Database."
}
},
"databasePassword": {
"type": "securestring",
"metadata": {
"description": "The password for the Contact Database."
}
}
}
}
3 changes: 3 additions & 0 deletions packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net472" />
<package id="Modernizr" version="2.8.3" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net472" />
<package id="NUnit" version="4.1.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="WebGrease" version="1.6.0" targetFramework="net472" />
</packages>