If I, as a learner who is continuously growing and changing, wish to change anything about my profile, I should be able to utilize an affordance on the frontend to edit any information I supplied within my registration. This should change the data persistently.
Acceptance Criteria
Endpoint URL: /user/update
When I, as a user, change information, a PATCH call should be sent to the backend to allow for the changing of user details.
Dependencies
All setup tickets must be completed before the completion of this ticket and the ability to obtain a user's details by an ID should be completed as well.
Dev Notes
PATCH, as pulled from NetflixBackendRare
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;
}
if (editedPost.Tags != null)
{
postToEdit.Tags = new List<Tag>();
foreach (var tag in editedPost.Tags)
{
var newTag = db.Tags.SingleOrDefault(t => t.Id == tag.Id);
postToEdit.Tags.Add(newTag);
}
}
db.SaveChanges();
return Results.Ok(postToEdit);
});
User Story
If I, as a learner who is continuously growing and changing, wish to change anything about my profile, I should be able to utilize an affordance on the frontend to edit any information I supplied within my registration. This should change the data persistently.
Acceptance Criteria
Endpoint URL: /user/update When I, as a user, change information, a PATCH call should be sent to the backend to allow for the changing of user details.
Dependencies
Dev Notes
PATCH, as pulled from NetflixBackendRare