// GET: DogController/Details/5 public ActionResult Details(int id) { Dog dog = _dogRepo.GetDogById(id); if (dog == null) { return(NotFound()); } List <Walk> walks = _walkRepo.GetWalksByDogId(id); DogProfileViewModel viewModel = new DogProfileViewModel { Dog = dog, Walks = walks.Where(walk => walk.WalkStatusId == 3).ToList() }; return(View(viewModel)); }
// GET: DogController1/Details/5 public ActionResult Details(int id) { Dog dog = _dogRepo.GetDogById(id); List <Walk> walks = _walkRepo.GetWalksByDogId(id); int currentUserId = GetCurrentUserId(); if (dog.OwnerId != currentUserId) { return(NotFound()); } if (dog == null) { return(NotFound()); } DogProfileViewModel vm = new DogProfileViewModel() { Dog = dog, Walks = walks }; return(View(vm)); }