I, as a student whose classes may change in their scope, duration, or facet must be able to make changes to any of the classes I wish to create as well.
Acceptance Criteria
Endpoint URL: '/class/{id}'
WHEN a user selects on a frontend button for a specific class, that ID as well as the changes made to the class form will be sent to the database so that the existing class 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