Edit function does not work
So I would like a second set of eyes. I wanted to try editing the pre-existing record on my card view (see the screenshot attached) like Beachfront Villa -> Beachfront Villa 8. Even this easy modification does not succeed, as on clicking the save button I got "record not found"
And this comes from here in the controller
and this is what the frontend devtool says: https://imgur.com/a/xs8LLlD
my database has not the id "1" referred in that devtool:
`
my save button on View should have been picking up any ids listed here (5,6, or 74) but as the devtool shows it picks up 1 instead. i suppose if it picks up 5,6,74 it will let me edit the ListingName property.
so could anyone kindly point me in the right direction? Relevant code snippets here https://pastebin.com/9U9zjvaG
Imgur
Untitled Album
Pastebin
/Controller/ public IActionResult Edit(int? Id) { if (I...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
10 Replies
What is
ListingProject
?Does it have only and exactly those properties?

?
Not at all
In my IDE the ListingProject has properties as follows
it is strange for me that my app thinks my listingProject class looks like that
public class ListingProject
{
public int Id { get; set; }
public string ListingName { get; set; }
public string __RequestVerificationToken { get; set; }
}`
I have no idea why. Do you have idea?It's not strange
That's the data you submit
The database models should never leave the application's boundary
Can you help me understand why my code submitted this data? I mean this
`
Not this
`
Can you also help me understand why my database model left the application's boundary? I just would like more clarity in that
Your code submitted this data, because it's what you told it to submit:

And the database model left the boundary when you used it as input expected by the API endpoint:

`
I rewrote the code like this. does the database model leave the "boundary" with this snippet too?
The action takes a DTO in this case, not the database entity
In this case, we return that DTO instead of returning a database entity
Each action can have its own DTO, you don't need to reuse them
If the
Get
action should not be returning the birthday, for example, just make another DTO that only has the name and the surname
(DTO — Data Transfer Object)