I'm trying to go through the NerdDinner example chapter from the ASP.Net MVC 1.0 and I've come across an error. Everything was hunky dory until I got to the part where I need to edit a dinner. I've followed the guide word for word from the creation of the project until this point (at least the best I can tell). However, when I call the SubmitChanges method on the NerdDinnerDataContext object I get an exception that says:
Rule violations prevent saving
I don't notice any differences between my code right now and the code that is in the final project (other than some additional functionality that I haven't added yet, obviously). Basically, I have no idea how to go about troubleshooting this error at this point. I've tried to look for some answers online, with no luck.
Here are some code snippets from my project, though I'm not sure how much good they will be.
from my DinnerRepository class:
private NerdDinnerDataContext db = new NerdDinnerDataContext();
...
public void Save()
{
db.SubmitChanges();
}
from the DinnersController
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, FormCollection formValues)
{
// Retrieve existing dinner
Dinner dinner = dinnerRepository.GetDinner(id);
// Update dinner with form posted values
dinner.Title = Request.Form["Title"];
dinner.Description = Request.Form["Description"];
dinner.EventDate = DateTime.Parse(Request.Form["EventDate"]);
dinner.Address = Request.Form["Address"];
dinner.Country = Request.Form["Country"];
dinner.ContactPhone = Request.Form["ContactPhone"];
// Persist changes back to database
dinnerRepository.Save();
// Perform HTTP redirect to details page for the saved Dinner
return RedirectToAction("Details", new { id = dinner.DinnerID });
}
How can I go about troubleshooting this issue? How can I find what these "rule violations" are?
This is my first SO question, so my apologies if it isn't that great.