This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello,
In this app I am working on, I am using MVC and working on tightening the data validation. One thing I do is like this: Book book = new Book(); book.Name = name; book.User = user; // set a relationship if(!book.IsValid) { // render a view that shows error message } The problem is that in the view I render, it also shows a list of the user's books and the invalid one is showing up in that list. I have to add a "users.Books.Remove(book)" call. Is there a better way to handle this though? I tried using a transaction around the entire method and calling Rollback before going to render the view, but it was still showing up. |
|
|
Could you set the view to render only valid books, e.g. make the viewdata user.Books.Where(b => b.IsValid) rather than just user.Books? |
|