public ActionResult Profile() { int id = GetCurrentUserId(); Owner owner = _ownerRepository.GetOwnerById(id); List <Dog> dogs = _dogRepository.GetDogsByOwnerId(owner.Id); List <Walker> walkers = _walkerRepository.GetWalkersInNeighborhood(owner.NeighborhoodId); ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers }; return(View("Details", vm)); }
// GET: WalkersController //sets action of Index() so that when it is call in StartUp.cs it will show list of walkers //public ActionResult AssociatedWalks() //{ //} public ActionResult Index() { if (User.IsInRole("Walker") && User.Identity.IsAuthenticated) { int id = GetCurrentWalker(); Owner owner = _ownerRepo.GetOwnerById(id); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); List <Neighborhood> neighborhood = _neighborhoodRepo.GetNeighborhoodsById(owner.NeighborhoodId); LocalWalkerListViewModel vm = new LocalWalkerListViewModel { Walker = walkers, Neighborhoods = neighborhood }; return(View(vm)); } else { List <Walker> walkers = _walkerRepo.GetAllWalkers(); List <Neighborhood> neighborhood = _neighborhoodRepo.GetAll(); LocalWalkerListViewModel vm = new LocalWalkerListViewModel { Walker = walkers, Neighborhoods = neighborhood }; return(View(vm)); } }
// GET: OwnersController/Details/5 public ActionResult Details(int id) { //int currentUserId = GetCurrentUserId(); //if (currentUserId != id) //{ // return NotFound(); //} Owner owner = _ownerRepo.GetOwnerById(id); List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); OwnerProfileViewModel vm = new OwnerProfileViewModel() { Owner = owner, Dog = dogs, WalkersInNeighborhood = walkers }; if (owner == null) { return(NotFound()); } return(View(vm)); }
// GET: Walks/Create public ActionResult Create() { int ownerId = GetCurrentUserId(); Owner owner = _ownerRepo.GetOwnerById(ownerId); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); List <Dog> dogs = _dogRepo.GetDogsByOwnerId(ownerId); List <SelectListItem> items = new List <SelectListItem>(); WalkFormViewModel vm = new WalkFormViewModel() { Walk = new Walk(), Walkers = walkers, Dogs = dogs }; return(View(vm)); }
// GET: Walkers where neighborhoodId matches neighboorhoodId of owner who is logged in //ActionResult is MVC thing, it created the index for us //we declared we wanted to enstaniate list in this method that contains all walkers linked to the walkers table that is accessed through the walkers Repository //returns a view result and passed in walkers, need to create a walkers view, and Razor does it for us //INDEX is the default path wen going to the view for this controller //if not logged in GetCurrent UserID returns 0 // then the GetOwnerById returns null since there is no id of 0 // if owner is null, list all // if owner exists then get walkers by neighorhoodid equal to the owner.NeighborhoodId public ActionResult Index() { Owner owner = _ownerRepo.GetOwnerById(GetCurrentUserId()); if (owner == null) { List <Walker> allWalkers = _walkerRepo.GetAllWalkers(); return(View(allWalkers)); } List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); return(View(walkers)); }
// GET: WalkersController public ActionResult Index() { int currentUserId = GetCurrentUserId(); Owner owner = _ownerRepo.GetOwnerById(currentUserId); Walker walker = _walkerRepo.GetWalkerById(currentUserId); List <Walker> walkers = new List <Walker>(); if (owner != null) { //only show walkers in user's neighborhood walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); } if (walker != null) { walkers = _walkerRepo.GetWalkersInNeighborhood(walker.NeighborhoodId); } if (walker == null && owner == null) { walkers = _walkerRepo.GetAllWalkers(); } return(View(walkers)); }
///// End Starter ///// // GET: WalkersController public ActionResult Index() { try { int loggedInUser = GetCurrentUserId(); Owner thisUser = _ownerRepo.GetOwnerById(loggedInUser); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(thisUser.NeighborhoodId); return(View(walkers)); } catch { List <Walker> walkers = _walkerRepo.GetAllWalkers(); return(View(walkers)); } }
// GET: Owners/Details/5 public ActionResult Details(int id) { Owner owner = _ownerRepo.GetOwnerById(id); List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers }; return(View(vm)); }
// GET: Walkers public ActionResult Index() { int ownerId = GetCurrentUserId(); if (ownerId > 0) { Owner currentOwner = _ownerRepo.GetOwnerById(ownerId); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(currentOwner.Neighborhood.Id); return(View(walkers)); } List <Walker> allWalkers = _walkerRepo.GetAllWalkers(); return(View(allWalkers)); }
//Gets the walkers from the Walker Table //Using the GetAllWalkers method from the WalkerRepository //Converts it to a list //Passes it off to the View public IActionResult Index() { try { int ownerId = GetCurrentUserId(); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(ownerId); return(View(walkers)); } catch { List <Walker> allWalkers = _walkerRepo.GetAllWalkers(); return(View(allWalkers)); } }
// GET: WalkersController public ActionResult Index() { if (User.FindFirstValue(ClaimTypes.NameIdentifier) != null) { Owner owner = _ownerRepo.GetOwnerById(int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier))); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); return(View(walkers)); } else { List <Walker> walkers = _walkerRepo.GetAllWalkers(); return(View(walkers)); } }
// GET: Walkers public ActionResult Index() { Owner owner = _ownerRepo.GetOwnerById(GetCurrentUserId()); List <Walker> closeWalkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); List <Walker> walkers = _walkerRepo.GetAllWalkers(); if (owner.Id == GetCurrentUserId()) { return(View(closeWalkers)); } else { return(View(walkers)); } }
// GET: Walkers public ActionResult Index() { string id = User.FindFirstValue(ClaimTypes.NameIdentifier); if (id != null) { int ownerId = int.Parse(id); Owner currentOwner = _ownerRepo.GetOwnerById(ownerId); List <Walker> ownerNeighborhoodWalkers = _walkerRepo.GetWalkersInNeighborhood(currentOwner.NeighborhoodId); return(View(ownerNeighborhoodWalkers)); } List <Walker> walkers = _walkerRepo.GetAllWalkers(); return(View(walkers)); }
// GET: WalksController/Create public ActionResult Create() { int currentUserId = GetCurrentUserId(); Owner thisOwner = _ownerRepo.GetOwnerById(currentUserId); Walk walk = new Walk(); WalkFormViewModel vm = new WalkFormViewModel() { Walkers = _walkerRepo.GetWalkersInNeighborhood(thisOwner.NeighborhoodId), Dogs = _dogRepo.GetDogsByOwnerId(thisOwner.Id), WalkStatuses = _walkStatusRepo.GetWalkStatuses(), Walk = walk }; return(View(vm)); }
//// GET: Owners/Details/5 //public ActionResult Details(int id) //{ // Owner owner = _ownerRepo.GetOwnerById(id); // if (owner == null) // { // return NotFound(); // } // return View(owner); //} //Chp 5 model view method // GET: Owners/Details/5 public ActionResult Details(int id) { Owner owner = _ownerRepo.GetOwnerById(id); List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); //We used the items declared above.....to pair our new lists/paramenters with the requested Id //and then shoved it into a profileVIEW, then we returned it. (Had to change details panel) ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers }; return(View(vm)); }
// GET: Walkers public ActionResult Index() { int currentUserId = GetCurrentUserId(); List <Walker> walkers = new List <Walker>(); if (currentUserId != 0) { Owner currentUser = _ownerRepo.GetOwnerById(currentUserId); walkers = _walkerRepo.GetWalkersInNeighborhood(currentUser.NeighborhoodId); } else { walkers = _walkerRepo.GetAllWalkers(); } return(View(walkers)); }
//In the context of ASP.NET, each of the public methods in the controllers is considered an Action. When our application receives incoming HTTP requests, The ASP.NET framework is smart enough to know which controller Action to invoke. // GET: WalkersConstrollers //This code will get all the walkers in the Walker table, convert it to a List and pass it off to the view. public ActionResult Index(int id) { //if they are log in then only let them see the walkers that are in their neighborhood //otherwise let them see all the walkers try { int ownerId = GetCurrentUserId(); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(ownerId); return(View(walkers)); } catch { List <Walker> walkers = _walkerRepo.GetAllWalkers(); return(View(walkers)); } }
// GET: Owners/Details/5 //int id comes from the URL public ActionResult Details(int id) { Owner owner = _ownerRepo.GetOwnerById(id); List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); //using neighbrohood id to grab all the walkers in that neighborhood List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers }; //vm is short for view model return(View(vm)); }
// GET: OwnersController/Details/5 public ActionResult Details(int id) { //Bring in the owner and list of dogs and walkers Owner owner = _ownerRepo.GetOwnerById(id); List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); //creating an Oject that holds owner and the list of dogs and walkers ProfileViewModel vm = new ProfileViewModel { Owner = owner, Dogs = dogs, Walkers = walkers }; //returning the view model return(View(vm)); }
// GET: OwnersController/Details/5 public ActionResult Details(int id) { // List the required elements needed to render the view the user should see // 1: An Owner object Owner owner = _ownerRepo.GetOwnerById(id); // 2: A list of Dogs List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); // 3: A list of Walkers List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers }; return(View(vm)); }
// GET: HomeController1 public ActionResult Index() { //checks to see if user is logged in int ownerId; bool result = int.TryParse(User.FindFirstValue(ClaimTypes.NameIdentifier), out ownerId); List <Walker> walkers = new List <Walker>(); if (result) { Owner owner = _ownerRepo.GetOwnerById(ownerId); walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); } else { walkers = _walkerRepo.GetAllWalkers(); } return(View(walkers)); }
// GET: OwnersController/Details/5 public ActionResult Details(int id) { // Getting the correct owner object Owner owner = _ownerRepo.GetOwnerById(id); // Getting the dogs that belong to that owner List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); // Getting the walkers in the owner''s neighborhood List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); // Package it up ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers }; return(View(vm)); }
// GET: WalkersController public ActionResult Index() { int ownerId = GetCurrentUserId(); if (ownerId == 0) { List <Walker> allWalkers = _walkerRepo.GetAllWalkers(); return(View(allWalkers)); } //pulls in the entire owner object(which has a neighborhoodId on it) Owner currentOwner = _ownerRepo.GetOwnerById(ownerId); //this code will get all the walkers in the Walker table //convert it to a list and pass it off to the view List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(currentOwner.NeighborhoodId); return(View(walkers)); }
// GET: OwnerController1/Details/5 public ActionResult Details() { int ownerId = GetCurrentOwner(); Owner owner = _ownerRepo.GetOwnerById(ownerId); List <Dog> dogs = _dogRepo.GetDogsByOwnerId(ownerId); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers }; if (owner == null) { return(NotFound()); } return(View(vm)); }
// GET: WalkersController public ActionResult Index() { List <Walker> allWalkers = _walkerRepo.GetAllWalkers(); try { int ownerId = GetCurrentUserId(); Owner owner = _ownerRepo.GetOwnerById(ownerId); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); if (owner == null || walkers == null || allWalkers == null) { return(NotFound()); } else { return(View(walkers)); } } catch (Exception ex) { return(View(allWalkers)); } }
// GET: OwnersController/Details/5 public ActionResult Details(int id) { Owner owner = _ownerRepo.GetOwnerById(id); if (owner == null) { return(NotFound()); } List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); List <Walk> walks = _walkRepo.GetUpcomingWalksByOwnerId(owner.Id); ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers, UpcomingWalks = walks }; return(View(vm)); }
// GET: Walkers public ActionResult Index() { int ownerId = GetCurrentUserId(); List <Walker> walkers = new List <Walker>() { }; if (ownerId != 0) { Owner owner = _ownerRepo.GetOwnerById(ownerId); int neighborhoodId = owner.NeighborhoodId; walkers = _walkerRepo.GetWalkersInNeighborhood(neighborhoodId); return(View(walkers)); } walkers = _walkerRepo.GetAllWalkers(); return(View(walkers)); }
// GET: OwnerController/Details/5 public ActionResult Details(int id) { int currentUser = GetCurrentUserId(); if (id != currentUser) { return(NotFound()); } Owner owner = _ownerRepository.GetOwnerById(id); List <Dog> dogs = _dogRepository.GetDogByOwnerId(owner.Id); List <Walker> walkers = _walkerRepository.GetWalkersInNeighborhood(owner.NeighborhoodId); List <Walk> walks = _walkRepository.GetWalksByOwnerId(currentUser); ProfileViewModel vm = new ProfileViewModel() { Owner = owner, Dogs = dogs, Walkers = walkers, Walks = walks }; return(View(vm)); }
// GET: OwnersController/Details/5 //this owners controller will get the id number from the url and that is what is //being passed into the Details method; public ActionResult Details(int id) { //get the one owner by Id (user is clicking on this owner) Owner owner = _ownerRepo.GetOwnerById(id); //pass this owner's Id into the method that gets a list of dogs by that ownerId List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id); //get a list of walkers by the owner's neighborhoodId List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId); //create new instance of your ProfileViewModel ProfileViewModel vm = new ProfileViewModel() { //these are setting the properties in your ProfileViewModel class to their respective values //which we obtained from above; Owner = owner, Dogs = dogs, Walkers = walkers }; //controller class then passes this information to the Razor view; return(View(vm)); }