I, as a student whose insights and ideas may change in their scope, duration, or facet must be able to make changes to any of the notes I take.
Acceptance Criteria
Endpoint URL: '/notes/{id}'
WHEN a user selects on a frontend button for a specific note, that ID as well as the changes made to the note form will be sent to the database so that the existing note data can be patched to reflect changes requested on the frontend.
Dependencies
All setup tickets must be completed before work can be done on this ticket.
Dev Notes
EDITING A POST EXAMPLE, backendnetflixrare
app.MapPatch("/api/posts/{postId}", (RareDbContext db, int postId, Post editedPost) =>
{
var postToEdit = db.Posts.FirstOrDefault(p => p.Id == postId);
if (postToEdit == null)
{
return Results.NotFound();
}
if (editedPost.Category_Id != null)
{
postToEdit.Category_Id = editedPost.Category_Id;
}
if (editedPost.Title != null)
{
postToEdit.Title = editedPost.Title;
}
if (editedPost.Publication_Date != null)
{
postToEdit.Publication_Date = editedPost.Publication_Date;
}
if (editedPost.Image_Url != null)
{
postToEdit.Image_Url = editedPost.Image_Url;
}
if (editedPost.Content != null)
{
postToEdit.Content = editedPost.Content;
}
if (editedPost.Approved != null)
{
postToEdit.Approved = editedPost.Approved;
}
db.SaveChanges();
return Results.Ok(postToEdit);
});
User Story
Acceptance Criteria
Dependencies
Dev Notes
EDITING A POST EXAMPLE, backendnetflixrare