diff --git a/.github/workflows/master_subratkumar.yml b/.github/workflows/master_subratkumar.yml
new file mode 100644
index 00000000..d794a113
--- /dev/null
+++ b/.github/workflows/master_subratkumar.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 app to Azure Web App - SubratKumar
+
+on:
+ push:
+ branches:
+ - master
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: windows-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Setup MSBuild path
+ uses: microsoft/setup-msbuild@v1.0.2
+
+ - name: Setup NuGet
+ uses: NuGet/setup-nuget@v1.0.5
+
+ - 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: 'SubratKumar'
+ slot-name: 'Production'
+ package: .
+ publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_72415876F92143C298770C359058EA69 }}
\ No newline at end of file
diff --git a/CRUD application 2.csproj b/CRUD application 2.csproj
index 553546be..0b82fcde 100644
--- a/CRUD application 2.csproj
+++ b/CRUD application 2.csproj
@@ -45,6 +45,9 @@
4
+
+ packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
+
@@ -111,11 +114,6 @@
packages\Antlr.3.5.0.2\lib\Antlr3.Runtime.dll
-
-
- packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
-
-
@@ -138,6 +136,8 @@
+
+
@@ -222,4 +222,4 @@
-->
-
+
\ No newline at end of file
diff --git a/Controllers/UserController.cs b/Controllers/UserController.cs
index f9ecbda2..7067487f 100644
--- a/Controllers/UserController.cs
+++ b/Controllers/UserController.cs
@@ -1,7 +1,7 @@
using CRUD_application_2.Models;
using System.Linq;
using System.Web.Mvc;
-
+
namespace CRUD_application_2.Controllers
{
public class UserController : Controller
@@ -10,57 +10,102 @@ public class UserController : Controller
// GET: User
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
+ try
+ {
+ userlist.Add(user);
+ return RedirectToAction("Index");
+ }
+ catch
+ {
+ return View();
+ }
}
-
+
// 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)
{
- // This method is responsible for handling the HTTP POST request to update an existing user with the specified ID.
- // It receives user input from the form submission and updates the corresponding user's information in the userlist.
- // 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.
+ try
+ {
+ var userToUpdate = userlist.FirstOrDefault(u => u.Id == id);
+ if (userToUpdate == null)
+ {
+ return HttpNotFound();
+ }
+ userlist.Remove(userToUpdate);
+ userlist.Add(user);
+ return RedirectToAction("Index");
+ }
+ catch
+ {
+ return View(user);
+ }
}
-
+
// 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
+ try
+ {
+ var user = userlist.FirstOrDefault(u => u.Id == id);
+ if (user != null)
+ {
+ userlist.Remove(user);
+ }
+ return RedirectToAction("Index");
+ }
+ catch
+ {
+ return View();
+ }
}
}
}
+
diff --git a/Web.config b/Web.config
index d246aab1..8ce4f449 100644
--- a/Web.config
+++ b/Web.config
@@ -30,7 +30,7 @@
-
+
diff --git a/deploy.json b/deploy.json
new file mode 100644
index 00000000..b57f068c
--- /dev/null
+++ b/deploy.json
@@ -0,0 +1,55 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "parameters": {
+ "webAppName": {
+ "type": "string",
+ "metadata": {
+ "description": "Name of the Web App"
+ }
+ },
+ "appServicePlanName": {
+ "type": "string",
+ "metadata": {
+ "description": "Name of the App Service Plan"
+ }
+ },
+ "location": {
+ "type": "string",
+ "defaultValue": "[resourceGroup().location]",
+ "metadata": {
+ "description": "Location for all resources."
+ }
+ }
+ },
+ "variables": {},
+ "resources": [
+ {
+ "type": "Microsoft.Web/serverfarms",
+ "apiVersion": "2020-06-01",
+ "name": "[parameters('appServicePlanName')]",
+ "location": "[parameters('location')]",
+ "sku": {
+ "name": "F1",
+ "tier": "Free"
+ },
+ "properties": {
+ "targetWorkerCount": 0,
+ "targetWorkerSizeId": 0
+ }
+ },
+ {
+ "type": "Microsoft.Web/sites",
+ "apiVersion": "2020-06-01",
+ "name": "[parameters('webAppName')]",
+ "location": "[parameters('location')]",
+ "dependsOn": [
+ "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]"
+ ],
+ "properties": {
+ "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlanName'))]"
+ }
+ }
+ ],
+ "outputs": {}
+}
diff --git a/deploy.parameters.json b/deploy.parameters.json
new file mode 100644
index 00000000..34646534
--- /dev/null
+++ b/deploy.parameters.json
@@ -0,0 +1,15 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
+ "contentVersion": "1.0.0.0",
+ "parameters": {
+ "webAppName": {
+ "value": "SubratKumar"
+ },
+ "appServicePlanName": {
+ "value": "Basic"
+ },
+ "location": {
+ "value": "West US 2"
+ }
+ }
+}
\ No newline at end of file