Skip to content

add two json file #49

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 5 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/master_subratkumar.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 - SubratKumar

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 }}

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 }}
12 changes: 6 additions & 6 deletions CRUD application 2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<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="System" />
<Reference Include="System.Data" />
Expand Down Expand Up @@ -111,11 +114,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 All @@ -138,6 +136,8 @@
<Content Include="Content\Site.css" />
<Content Include="Scripts\bootstrap.js" />
<Content Include="Scripts\bootstrap.min.js" />
<Content Include="deploy.json" />
<Content Include="deploy.parameters.json" />
<None Include="Scripts\jquery-3.4.1.intellisense.js" />
<Content Include="Scripts\jquery-3.4.1.js" />
<Content Include="Scripts\jquery-3.4.1.min.js" />
Expand Down Expand Up @@ -222,4 +222,4 @@
</Target>
<Target Name="AfterBuild">
</Target> -->
</Project>
</Project>
87 changes: 66 additions & 21 deletions Controllers/UserController.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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();
}
}
}
}

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
55 changes: 55 additions & 0 deletions deploy.json
Original file line number Diff line number Diff line change
@@ -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": {}
}
15 changes: 15 additions & 0 deletions deploy.parameters.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}