Skip to content

Add deploy settings, UserController implementation #19

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 3 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
11 changes: 5 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,7 @@
<Content Include="Content\Site.css" />
<Content Include="Scripts\bootstrap.js" />
<Content Include="Scripts\bootstrap.min.js" />
<Content Include="armtemplate.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 +221,4 @@
</Target>
<Target Name="AfterBuild">
</Target> -->
</Project>
</Project>
10 changes: 8 additions & 2 deletions CRUD application 2.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject2", "..\UnitTestProject2\UnitTestProject2.csproj", "{B1050339-D0AD-437C-86D2-80746A3E6A76}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{D44C1C21-0289-4DD0-B139-6825EE5C13B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D44C1C21-0289-4DD0-B139-6825EE5C13B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D44C1C21-0289-4DD0-B139-6825EE5C13B2}.Release|Any CPU.Build.0 = Release|Any CPU
{B1050339-D0AD-437C-86D2-80746A3E6A76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1050339-D0AD-437C-86D2-80746A3E6A76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1050339-D0AD-437C-86D2-80746A3E6A76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1050339-D0AD-437C-86D2-80746A3E6A76}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
86 changes: 73 additions & 13 deletions Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,117 @@ public class UserController : Controller
// GET: User
public ActionResult Index()
{
// Implement the Index method here
return View(userlist);
}

// GET: User/Details/5
[HttpGet]
[Route("user/details{id}")]
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
[HttpGet]
[Route("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
[HttpGet]
[Route("User/Edit{id}")]
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]
[Route("User/Edit{id}")]
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.
var existingUser = userlist.FirstOrDefault(u => u.Id == id);
if (existingUser == null)
{
return HttpNotFound();
}
if (ModelState.IsValid)
{
existingUser.Name = user.Name;
existingUser.Email = user.Email;
// Add other properties as needed
return RedirectToAction("Index");
}
return View(user);

}

// GET: User/Delete/5
[HttpGet]
[Route("User/Search{id}")]
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]
[Route("User/Delete{id}")]
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");
}

// GET: User/Search
[HttpGet]
[Route("User/Search/{name}")]
public ActionResult Search(string name)
{
var users = userlist.Where(u => u.Name.Contains(name)).ToList();
return View("Index", users);
}
}
}
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
38 changes: 38 additions & 0 deletions armtemplate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string",
"metadata": {
"description": "The name of the web app that you wish to create."
}
},
"hostingPlanName": {
"type": "string",
"metadata": {
"description": "The name of the App Service plan to use for hosting the web app."
}
},
"location": {
"type": "string",
"metadata": {
"description": "The location (region) to create the web app."
}
}
},
"resources": [
{
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
}
}
]
}
77 changes: 77 additions & 0 deletions deploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"type": "string",
"metadata": {
"description": "Base name of the resource such as web app name and app service plan"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources"
}
}
},
"variables": {
"appServicePlanName": "[concat(parameters('webAppName'), 'ServicePlan')]"
},
"resources": [
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2020-06-01",
"name": "[variables('appServicePlanName')]",
"location": "[parameters('location')]",
"sku": {
"name": "F1",
"capacity": 1
},
"kind": "app"
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2020-06-01",
"name": "[parameters('webAppName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
],
"kind": "app",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"alwaysOn": true,
"scmType": "None"
},
"httpsOnly": true
},
"identity": {
"type": "SystemAssigned"
},
"resources": [
{
"name": "authsettings",
"type": "config",
"apiVersion": "2020-06-01",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', parameters('webAppName'))]"
],
"properties": {
"enabled": true,
"unauthenticatedClientAction": "RedirectToLoginPage",
"defaultProvider": "AzureActiveDirectory"
}
}
]
}
],
"outputs": {
"webAppUrl": {
"type": "string",
"value": "[concat('https://', parameters('webAppName'), '.azurewebsites.net')]"
}
}
}
12 changes: 12 additions & 0 deletions deploy.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"webAppName": {
"value": "MyCopilottrainingAPP"
},
"location": {
"value": "East US"
}
}
}