I want to update a value in my model using Neo4j official driver for .Net in asp.net mvc app. My code is as:
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit(string name, Category category)
{
try
{
var oldName = name.ToString();
var newName = category.Name.ToString();
using (var session = _driver.Session())
{
session.WriteTransaction(tx =>
{
tx.Run("Match (a:Category) WHERE a.Name = '$oldName' Set a.Name = '$newName'", new { oldName, newName });
});
}
return RedirectToAction(nameof(Index));
}
catch
{
return View();
}
}
But the code results with no changes. Why?
Model class:
public class Category
{
public string Name { get; set; }
}
And I get the name
value from this code in View:
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { name = item.Name/* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}