I used List, Create, and Edit Scaffolding Views with the Product model "@model Nop.Core.Domain.Catalog.Product"
List and Create both work.
But having trouble with Edit. The Edit screen displays the form with the fields I have chosen.
But when I click "Save" it doesn't update any of the fields:
public ActionResult Edit(int id)
{
var product = _productService.GetProductById(id);
return View(product);
}
[HttpPost]
public ActionResult Edit(Product model)
{
model.AdminComment = "test";
_productService.UpdateProduct(model); // doesn't work
return RedirectToAction("Index");
}
View:
@model Nop.Core.Domain.Catalog.Product
@using (Html.BeginForm())
{
@Html.HiddenFor(model => model.Id)
<div class="form-group">
@Html.LabelFor(model => model.Name, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
.............
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
........
}
I also tried : _productRepository.Update(model); but that didn't work either.
The "_productService.InsertProduct(model)" works but "_productService.UpdateProduct(model)" doesn't.
In the Nop.Admin Edit code, it looks like this : public ActionResult Edit(ProductModel model, bool continueEditing) { . .
But the ProductModel is in the Admin project and I can't access it.
But the Create works with just the Product model.
Can anyone see why the Edit is not updating?
Thanks