// GET: Posts/Details/5 public ActionResult Details(int?id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} //Posts posts = db.Posts.Find(id); //if (posts == null) //{ // return HttpNotFound(); //} //return View(posts); Posts posts = db.Posts.Find(id); var qPict = db.Picts.Where(q => q.PostFK == id).ToList(); var viewModel = new MainDetailViewModel { ID = posts.ID, PostTitle = posts.PostTitle, PostAuthor = posts.PostAuthor, PostTags = posts.PostTags, PostText = posts.PostText, TitlePic = posts.TitlePic, EditDate = posts.EditDate, Picts = qPict, }; return(View(viewModel)); }
public MainDetail() { InitializeComponent(); BindingContext = new MainDetailViewModel(); }