Spaces:
Runtime error
Runtime error
Florin Bobiș
commited on
Commit
•
93c9c23
1
Parent(s):
0e97e34
wip
Browse files- Program.cs +39 -39
Program.cs
CHANGED
@@ -55,46 +55,46 @@ app.MapGet("/quotes", async (QuoteDbContext db, int pageNumber = 1, int pageSize
|
|
55 |
return Results.Ok(quotes);
|
56 |
});
|
57 |
|
58 |
-
app.MapGet("/quotes/{id}", async (int id, QuoteDbContext db) =>
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
app.MapPost("/quotes", async (Quote newQuote, QuoteDbContext db) =>
|
64 |
-
{
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
});
|
69 |
-
|
70 |
-
app.MapPut("/quotes/{id}", async (int id, Quote updatedQuote, QuoteDbContext db) =>
|
71 |
-
{
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
|
85 |
-
|
86 |
-
|
87 |
-
});
|
88 |
-
|
89 |
-
app.MapDelete("/quotes/{id}", async (int id, QuoteDbContext db) =>
|
90 |
-
{
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
});
|
98 |
|
99 |
// Random quote endpoint
|
100 |
app.MapGet("/quotes/random", async (QuoteDbContext db) =>
|
|
|
55 |
return Results.Ok(quotes);
|
56 |
});
|
57 |
|
58 |
+
// app.MapGet("/quotes/{id}", async (int id, QuoteDbContext db) =>
|
59 |
+
// await db.Quotes.FindAsync(id) is Quote quote
|
60 |
+
// ? Results.Ok(quote)
|
61 |
+
// : Results.NotFound("Quote not found"));
|
62 |
+
|
63 |
+
// app.MapPost("/quotes", async (Quote newQuote, QuoteDbContext db) =>
|
64 |
+
// {
|
65 |
+
// db.Quotes.Add(newQuote);
|
66 |
+
// await db.SaveChangesAsync();
|
67 |
+
// return Results.Created($"/quotes/{newQuote.Id}", newQuote);
|
68 |
+
// });
|
69 |
+
|
70 |
+
// app.MapPut("/quotes/{id}", async (int id, Quote updatedQuote, QuoteDbContext db) =>
|
71 |
+
// {
|
72 |
+
// var quote = await db.Quotes.FindAsync(id);
|
73 |
+
// if (quote is null) return Results.NotFound("Quote not found");
|
74 |
+
|
75 |
+
// quote.Author = updatedQuote.Author;
|
76 |
+
// quote.QuoteText = updatedQuote.QuoteText;
|
77 |
+
// quote.Source = updatedQuote.Source;
|
78 |
+
// quote.Book = updatedQuote.Book;
|
79 |
+
// quote.Categories = updatedQuote.Categories;
|
80 |
+
// quote.Url = updatedQuote.Url;
|
81 |
+
// quote.Isbn = updatedQuote.Isbn;
|
82 |
+
// quote.Language = updatedQuote.Language;
|
83 |
+
// quote.OriginalLanguage = updatedQuote.OriginalLanguage;
|
84 |
|
85 |
+
// await db.SaveChangesAsync();
|
86 |
+
// return Results.NoContent();
|
87 |
+
// });
|
88 |
+
|
89 |
+
// app.MapDelete("/quotes/{id}", async (int id, QuoteDbContext db) =>
|
90 |
+
// {
|
91 |
+
// var quote = await db.Quotes.FindAsync(id);
|
92 |
+
// if (quote is null) return Results.NotFound("Quote not found");
|
93 |
+
|
94 |
+
// db.Quotes.Remove(quote);
|
95 |
+
// await db.SaveChangesAsync();
|
96 |
+
// return Results.NoContent();
|
97 |
+
// });
|
98 |
|
99 |
// Random quote endpoint
|
100 |
app.MapGet("/quotes/random", async (QuoteDbContext db) =>
|