Skip to content

merging changes #22

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 4 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
66 changes: 66 additions & 0 deletions .github/workflows/master_contactdatabaseappabb.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 - contactDatabaseAppABB

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_D3CC6CE549B84F2EA2047F1D86FB3393 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_5424CE301AE7477CAD2D2176BB8319DB }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_078963FFAD5947C4B3EA64744CDE0D60 }}

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

10 changes: 4 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 Down Expand Up @@ -222,4 +220,4 @@
</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.10.34916.146
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
70 changes: 62 additions & 8 deletions Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,55 @@ public class UserController : Controller
// GET: User
public ActionResult Index()
{
// Implement the Index method here
return View(userlist);
}

public ActionResult Search(string searchTerm)
{
var results = userlist.Where(u => u.Name.Contains(searchTerm)).ToList();
return View(results);
}

// 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
if (ModelState.IsValid)
{
userlist.Add(user);
return RedirectToAction("Index");
}

return View(user);
}

// 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
Expand All @@ -48,19 +70,51 @@ 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.
// Find the user to be updated
var userToUpdate = userlist.FirstOrDefault(u => u.Id == id);
if (userToUpdate == null)
{
return HttpNotFound();
}

// Check if the model state is valid
if (ModelState.IsValid)
{
// Update the user's details
userToUpdate.Name = user.Name;
userToUpdate.Email = user.Email;

// Redirect to the Index view
return RedirectToAction("Index");
}

// If model state is not valid, return the Edit view to display any validation errors
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
var user = userlist.FirstOrDefault(u => u.Id == id);
if (user == null)
{
return HttpNotFound();
}

userlist.Remove(user);
return RedirectToAction("Index");
}
}
}
39 changes: 24 additions & 15 deletions Views/User/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
}

<h2>Index</h2>
@using (Html.BeginForm("Index", "User", FormMethod.Get))
{
<p>
Find by name: @Html.TextBox("searchString")
<input type="submit" value="Search" />
</p>
}

<p>
@Html.ActionLink("Create New", "Create")
</p>

<table class="table">
<tr>
<th>
Expand All @@ -20,20 +28,21 @@
<th></th>
</tr>

@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.Id })
</td>
</tr>
}
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Email)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Details", "Details", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</td>
</tr>
}

</table>
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
Loading