C#C
C#13mo ago
morry329#

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
`
 [HttpPost]
    public async Task<IActionResult> Update(ListingProjects updatedUserModelRef)
    {
        
        
        if (oldListingProjects == null)
        {
            if (Request.Headers["X-Requested-With"] == "XMLHttpRequest")
            {
                return Json(new { success = false, message = "Record not found." }); //this is the error i see on View
            }
            return NotFound();
        }


and this is what the frontend devtool says: https://imgur.com/a/xs8LLlD

my database has not the id "1" referred in that devtool:
 mysql> Select * from ListingDBTable;
+----+----------------------+----------------------------------+------------+------------+
| Id | ListingName          | ImageUrl                         | CategoryId | LocationId |
+----+----------------------+----------------------------------+------------+------------+
|  5 | Beachfront Villa     | http://example.com/villa.jpg     |          1 |          1 |
|  6 | hidden moon building | hiddenmoon                       |          1 |          1 |
| 74 | New Listing          | http://example.com/new_image.jpg |          1 |          1 |
+----+----------------------+----------------------------------+------------+------------+
`

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
Pastebin
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.
Was this page helpful?