开发者

How to define ASP.NET MVC view model for parent/child relationship and its view (*.cshtml)

I have a domain model below:

 public  class Book
 {
     public List<Author> Authors = new List<Author>();
 }

 public class Author
 {
     public Book Book { get; set; }
     public string Name { get; set; }
 }

I want to define an edit view for a book, below is the action methods:

public ActionResult BookEd开发者_运维问答it(int id)
{

    BookModel model = GetBook(id);
    return View(model);
}

[HttpPost]  
public ActionResult BookEdit(BookModel bookModel)
{

    BookModel model = new BookModel();
    return View(model);
}

Two questions:

Question 1: how to best define the view models for both Book and Author.

Question 2: How to define the view (*.cshtml), particularly on Book property of Author, which should be hidden. The other part has been resovled on Expose collections in view

Thanks

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜