Skip to content

Commit 30f0713

Browse files
update readme file
1 parent c878a03 commit 30f0713

File tree

22,519 files changed

+8019
-4238845
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

22,519 files changed

+8019
-4238845
lines changed

.vscode/extensions.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions"
4+
]
5+
}

.vscode/launch.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Attach to Node Functions",
6+
"type": "node",
7+
"request": "attach",
8+
"port": 9229,
9+
"preLaunchTask": "func: host start"
10+
}
11+
]
12+
}

.vscode/settings.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"dotnet.defaultSolution": "BlazorApp.sln"
3-
}
2+
"dotnet.defaultSolution": "BlazorApp.sln",
3+
"azureFunctions.deploySubpath": "Build Serverless APIs with Azure Functions\\mslearn-build-api-azure-functions\\api",
4+
"azureFunctions.postDeployTask": "npm install (functions)",
5+
"azureFunctions.projectLanguage": "TypeScript",
6+
"azureFunctions.projectRuntime": "~4",
7+
"debug.internalConsoleOptions": "neverOpen",
8+
"azureFunctions.preDeployTask": "npm prune (functions)"
9+
}

.vscode/tasks.json

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "func",
6+
"label": "func: host start",
7+
"command": "host start",
8+
"problemMatcher": "$func-node-watch",
9+
"isBackground": true,
10+
"dependsOn": "npm build (functions)",
11+
"options": {
12+
"cwd": "${workspaceFolder}/Build Serverless APIs with Azure Functions\\mslearn-build-api-azure-functions\\api"
13+
}
14+
},
15+
{
16+
"type": "shell",
17+
"label": "npm install (functions)",
18+
"command": "npm install",
19+
"options": {
20+
"cwd": "${workspaceFolder}/Build Serverless APIs with Azure Functions\\mslearn-build-api-azure-functions\\api"
21+
}
22+
},
23+
{
24+
"type": "shell",
25+
"label": "npm prune (functions)",
26+
"command": "npm prune --production",
27+
"dependsOn": "npm build (functions)",
28+
"problemMatcher": [],
29+
"options": {
30+
"cwd": "${workspaceFolder}/Build Serverless APIs with Azure Functions\\mslearn-build-api-azure-functions\\api"
31+
}
32+
},
33+
{
34+
"type": "shell",
35+
"label": "npm clean (functions)",
36+
"command": "npm run clean",
37+
"dependsOn": "npm install (functions)",
38+
"options": {
39+
"cwd": "${workspaceFolder}/Build Serverless APIs with Azure Functions\\mslearn-build-api-azure-functions\\api"
40+
}
41+
},
42+
{
43+
"type": "shell",
44+
"label": "npm build (functions)",
45+
"command": "npm run build",
46+
"dependsOn": "npm install (functions)",
47+
"problemMatcher": "$tsc",
48+
"options": {
49+
"cwd": "${workspaceFolder}/Build Serverless APIs with Azure Functions\\mslearn-build-api-azure-functions\\api"
50+
}
51+
}
52+
]
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Build Serverless APIs with Azure Functions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit dfb0a610e68c5eb7fa8384e4fc7c51782f8fb173

Build a web API with Node.js and Express/Build asp.net api and consume react/backend/.vs/backend/config/applicationhost.config

+1,011
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"Version": 1,
3+
"WorkspaceRootPath": "C:\\Github\\AzureModule\\Build a web API with Node.js and Express\\Build asp.net api and consume react\\backend\\",
4+
"Documents": [
5+
{
6+
"AbsoluteMoniker": "D:0:0:{070CA7F3-61DE-48C5-81E7-0558C10DD2E4}|backend.csproj|c:\\github\\azuremodule\\build a web api with node.js and express\\build asp.net api and consume react\\backend\\controllers\\todocontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
7+
"RelativeMoniker": "D:0:0:{070CA7F3-61DE-48C5-81E7-0558C10DD2E4}|backend.csproj|solutionrelative:controllers\\todocontroller.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
8+
},
9+
{
10+
"AbsoluteMoniker": "D:0:0:{070CA7F3-61DE-48C5-81E7-0558C10DD2E4}|backend.csproj|c:\\github\\azuremodule\\build a web api with node.js and express\\build asp.net api and consume react\\backend\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
11+
"RelativeMoniker": "D:0:0:{070CA7F3-61DE-48C5-81E7-0558C10DD2E4}|backend.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
12+
},
13+
{
14+
"AbsoluteMoniker": "D:0:0:{070CA7F3-61DE-48C5-81E7-0558C10DD2E4}|backend.csproj|c:\\github\\azuremodule\\build a web api with node.js and express\\build asp.net api and consume react\\backend\\appsettings.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}",
15+
"RelativeMoniker": "D:0:0:{070CA7F3-61DE-48C5-81E7-0558C10DD2E4}|backend.csproj|solutionrelative:appsettings.json||{90A6B3A7-C1A3-4009-A288-E2FF89E96FA0}"
16+
}
17+
],
18+
"DocumentGroupContainers": [
19+
{
20+
"Orientation": 0,
21+
"VerticalTabListWidth": 256,
22+
"DocumentGroups": [
23+
{
24+
"DockedWidth": 200,
25+
"SelectedChildIndex": 1,
26+
"Children": [
27+
{
28+
"$type": "Bookmark",
29+
"Name": "ST:1:0:{f2bd8fb8-fc94-3dae-a733-fd993c73cc87}"
30+
},
31+
{
32+
"$type": "Document",
33+
"DocumentIndex": 0,
34+
"Title": "TodoController.cs",
35+
"DocumentMoniker": "C:\\Github\\AzureModule\\Build a web API with Node.js and Express\\Build asp.net api and consume react\\backend\\Controllers\\TodoController.cs",
36+
"RelativeDocumentMoniker": "Controllers\\TodoController.cs",
37+
"ToolTip": "C:\\Github\\AzureModule\\Build a web API with Node.js and Express\\Build asp.net api and consume react\\backend\\Controllers\\TodoController.cs",
38+
"RelativeToolTip": "Controllers\\TodoController.cs",
39+
"ViewState": "AQIAAGoAAAAAAAAAAAAcwG4AAAAaAAAA",
40+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
41+
"WhenOpened": "2024-03-01T06:53:11.402Z",
42+
"EditorCaption": ""
43+
},
44+
{
45+
"$type": "Document",
46+
"DocumentIndex": 2,
47+
"Title": "appsettings.json",
48+
"DocumentMoniker": "C:\\Github\\AzureModule\\Build a web API with Node.js and Express\\Build asp.net api and consume react\\backend\\appsettings.json",
49+
"RelativeDocumentMoniker": "appsettings.json",
50+
"ToolTip": "C:\\Github\\AzureModule\\Build a web API with Node.js and Express\\Build asp.net api and consume react\\backend\\appsettings.json",
51+
"RelativeToolTip": "appsettings.json",
52+
"ViewState": "AQIAAAMAAAAAAAAAAAAAAAkAAAAOAAAA",
53+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001642|",
54+
"WhenOpened": "2024-03-01T06:50:12.441Z",
55+
"EditorCaption": ""
56+
},
57+
{
58+
"$type": "Document",
59+
"DocumentIndex": 1,
60+
"Title": "Program.cs",
61+
"DocumentMoniker": "C:\\Github\\AzureModule\\Build a web API with Node.js and Express\\Build asp.net api and consume react\\backend\\Program.cs",
62+
"RelativeDocumentMoniker": "Program.cs",
63+
"ToolTip": "C:\\Github\\AzureModule\\Build a web API with Node.js and Express\\Build asp.net api and consume react\\backend\\Program.cs",
64+
"RelativeToolTip": "Program.cs",
65+
"ViewState": "AQIAAAAAAAAAAAAAAAAAABsAAAAXAAAA",
66+
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
67+
"WhenOpened": "2024-03-01T06:34:41.332Z",
68+
"EditorCaption": ""
69+
}
70+
]
71+
}
72+
]
73+
}
74+
]
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
using Microsoft.AspNetCore.Http;
2+
using Microsoft.AspNetCore.Mvc;
3+
using System.Data;
4+
using System.Data.SqlClient;
5+
6+
namespace backend.Controllers
7+
{
8+
[Route("api/[controller]")]
9+
[ApiController]
10+
public class TodoController : ControllerBase
11+
{
12+
private IConfiguration _configuration;
13+
14+
15+
public TodoController(IConfiguration configuration)
16+
{
17+
_configuration = configuration;
18+
}
19+
20+
[HttpGet]
21+
[Route("GetNotes")]
22+
public JsonResult GetNotes()
23+
{
24+
string query = "select * from dbo.Notes";
25+
DataTable table = new DataTable();
26+
string sqlDatasource = _configuration.GetConnectionString("todoAppDB");
27+
SqlDataReader myReader;
28+
using(SqlConnection myCon=new SqlConnection(sqlDatasource))
29+
{
30+
myCon.Open();
31+
using(SqlCommand myCommand = new SqlCommand(query, myCon)) {
32+
myReader=myCommand.ExecuteReader();
33+
table.Load(myReader);
34+
myReader.Close();
35+
myCon.Close();
36+
}
37+
}
38+
return new JsonResult(table);
39+
}
40+
41+
[HttpPost]
42+
[Route("AddNotes")]
43+
public JsonResult AddNotes([FromForm] string newNotes)
44+
{
45+
string query = "insert into dbo.Notes values(@newNotes)";
46+
DataTable table = new DataTable();
47+
string sqlDatasource = _configuration.GetConnectionString("todoAppDB");
48+
SqlDataReader myReader;
49+
using(SqlConnection myCon=new SqlConnection(sqlDatasource))
50+
{
51+
myCon.Open();
52+
using(SqlCommand myCommand = new SqlCommand(query, myCon)) {
53+
myCommand.Parameters.AddWithValue("@newNotes", newNotes);
54+
myReader=myCommand.ExecuteReader();
55+
table.Load(myReader) ;
56+
myReader.Close();
57+
myCon.Close();
58+
}
59+
}
60+
return new JsonResult("Added Successfully");
61+
}
62+
63+
64+
[HttpGet]
65+
[Route("GetNotesById")]
66+
public JsonResult GetNotesById([FromForm] string id)
67+
{
68+
string query = "select * from dbo.Notes where id=@id";
69+
DataTable table = new DataTable();
70+
string sqlDatasource = _configuration.GetConnectionString("todoAppDB");
71+
SqlDataReader myReader;
72+
using (SqlConnection myCon = new SqlConnection(sqlDatasource))
73+
{
74+
myCon.Open();
75+
using (SqlCommand myCommand = new SqlCommand(query, myCon))
76+
{
77+
myReader = myCommand.ExecuteReader();
78+
table.Load(myReader);
79+
myReader.Close();
80+
myCon.Close();
81+
}
82+
}
83+
return new JsonResult(table);
84+
}
85+
86+
[HttpPost]
87+
[Route("UpdateNotes")]
88+
public JsonResult UpdateNotes(string id, string description)
89+
{
90+
string query = "update dbo.Notes set description=@description where id=@id";
91+
DataTable table = new DataTable();
92+
string sqlDatasource = _configuration.GetConnectionString("todoAppDB");
93+
SqlDataReader myReader;
94+
using (SqlConnection myCon = new SqlConnection(sqlDatasource))
95+
{
96+
myCon.Open();
97+
using (SqlCommand myCommand = new SqlCommand(query, myCon))
98+
{
99+
myCommand.Parameters.AddWithValue("@id", id);
100+
myCommand.Parameters.AddWithValue("@description", description);
101+
myReader = myCommand.ExecuteReader();
102+
table.Load(myReader);
103+
myReader.Close();
104+
myCon.Close();
105+
}
106+
}
107+
return new JsonResult("updated Successfully");
108+
}
109+
110+
[HttpDelete]
111+
[Route("DeleteNote")]
112+
public JsonResult DeleteNote([FromForm] string id)
113+
{
114+
string query = "delete from dbo.Notes where id=@id";
115+
DataTable table = new DataTable();
116+
string sqlDatasource = _configuration.GetConnectionString("todoAppDB");
117+
SqlDataReader myReader;
118+
using (SqlConnection myCon = new SqlConnection(sqlDatasource))
119+
{
120+
myCon.Open();
121+
using (SqlCommand myCommand = new SqlCommand(query, myCon))
122+
{
123+
myCommand.Parameters.AddWithValue("@id", id);
124+
myReader = myCommand.ExecuteReader();
125+
table.Load(myReader);
126+
myReader.Close();
127+
myCon.Close();
128+
}
129+
}
130+
return new JsonResult("Notes deleted Successfully");
131+
}
132+
}
133+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Newtonsoft.Json.Serialization;
2+
3+
var builder = WebApplication.CreateBuilder(args);
4+
5+
// Add services to the container.
6+
7+
builder.Services.AddControllers();
8+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
9+
builder.Services.AddEndpointsApiExplorer();
10+
builder.Services.AddSwaggerGen();
11+
12+
//JSON Serializer
13+
builder.Services.AddControllers().AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore).AddNewtonsoftJson(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
14+
15+
var app = builder.Build();
16+
17+
app.UseCors(c => c.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod());
18+
19+
// Configure the HTTP request pipeline.
20+
if (app.Environment.IsDevelopment())
21+
{
22+
app.UseSwagger();
23+
app.UseSwaggerUI();
24+
}
25+
26+
app.UseHttpsRedirection();
27+
28+
app.UseAuthorization();
29+
30+
app.MapControllers();
31+
32+
app.Run();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"$schema": "https://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:40956",
8+
"sslPort": 44338
9+
}
10+
},
11+
"profiles": {
12+
"backend": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"launchUrl": "swagger",
17+
"applicationUrl": "https://localhost:7156;http://localhost:5123",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
22+
"IIS Express": {
23+
"commandName": "IISExpress",
24+
"launchBrowser": true,
25+
"launchUrl": "swagger",
26+
"environmentVariables": {
27+
"ASPNETCORE_ENVIRONMENT": "Development"
28+
}
29+
}
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace backend
2+
{
3+
public class WeatherForecast
4+
{
5+
public DateTime Date { get; set; }
6+
7+
public int TemperatureC { get; set; }
8+
9+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
10+
11+
public string? Summary { get; set; }
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.AspNetCore": "Warning"
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)