产品。您可以跳到插入行并获得空异常消息。
public ActionResult Create([Bind(Include =“ ID,Name,CategoryId,Brand,Model,ImageUrl,Description,Price, 税收,折扣,库存, IsActive,CreateDate,CreateUserId,UpdateDate,UpdateUserId“)]产品, IEnumerable文件)
if (files != null&&files.Count()>0)
{
foreach (var item in files)
{
Tuple<string, string> paths = ImageUpload.SaveImageWithThumbnail(item, 329, 380, 84, 84, false);
product.Images.Add(new Images
{
ImageUrl = paths.Item1,
ImageUrlt = paths.Item2,
RegisterDate = DateTime.Now,
CreateDate = DateTime.Now,
CreateUserId = 1,
UpdateDate = DateTime.Now,
UpdateUserId = 1
});
}
}
**db.Products.Add(product);**
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.CategoryId = new SelectList(db.Categories, "ID", "Name", product.CategoryId);
return View(product);
}