public async Task <ActionResult> DoListByTag(ListByTagModel tagView) { CheckAda(); ApplicationUser user = await GetLoggedInUser(); //String Username = GetLoggedInUser(); //if (Username == null) //{ // return ForceLogin(); //} Tag tag = db.Tags.Find(tagView.Id); if (tag == null) { return(RedirectToAction("Error", "Home", new { ErrId = "ListByTag" })); } ViewBag.Username = user.UserName; /* * Eager loading of related entities */ var images = db.Entry(tag).Collection(t => t.Images).Query().Where(im => im.Approved).Include(im => im.User).ToList(); return(View("ListAll", tag.Images)); }
public ActionResult ListByTag() { CheckAda(); //if (GetLoggedInUser() == null) //{ // return ForceLogin(); //} ListByTagModel tagView = new ListByTagModel(); tagView.Tags = new SelectList(db.Tags, "Id", "Name", 1); return(View(tagView)); }