Exemple #1
0
        // GET: WalksCOntroller/Create
        public ActionResult Create()
        {
            List <Walker> walkers = _walkerRepo.GetAllWalkers();
            List <Dog>    dogs    = _dogRepo.GetAllDogs();
            WalkFormModel vm      = new WalkFormModel()
            {
                Walks   = new Walks(),
                Dogs    = dogs,
                Walkers = walkers
            };

            return(View(vm));
        }
        // GET: WalksController/Create
        public ActionResult Create()
        {
            List <Dog>    Dog    = _dogRepo.GetAllDogs();
            List <Walker> Walker = _walkerRepo.GetAllWalkers();

            WalksViewModel vm = new WalksViewModel
            {
                Dog    = Dog,
                Walker = Walker,
                Walk   = new Walks()
            };

            return(View(vm));
        }
Exemple #3
0
        // GET: WalkersController
        // When a user is on localhost:5001/Walkers, we want to show them a view that contains a list of all the walkers in our system.

        // GET: Walkers
        public ActionResult Index()
        {
            // 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.GetAllWalkers();

            return(View(walkers));
        }
Exemple #4
0
        // 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: WalkersController; Index method gets all the data and then hands it off to be rendered to HTML
        public ActionResult Index()
        {
            int ownerId = GetCurrentUserId();

            List <Walker> walkers = _walkerRepo.GetAllWalkers(ownerId);

            return(View(walkers));
        }
Exemple #6
0
        // GET: WalkersController
        public ActionResult Index()
        {
            int   currentUserId = GetCurrentUserId();
            Owner currentOwner  = _ownerRepo.GetOwnerById(currentUserId);

            List <Walker> walkers = _walkerRepo.GetAllWalkers();

            return(View(walkers.Where(walker => walker.NeighborhoodId == currentOwner.NeighborhoodId)));
        }
Exemple #7
0
        // 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));
        }
Exemple #8
0
        // GET: WalksController/Create
        public ActionResult Create()
        {
            //getting list of all the walkers
            List <Walker> walkers = _walkerRepo.GetAllWalkers();
            //getting list of all the dogs
            List <Dog> dogs = _dogRepo.GetAllDogs();
            //this will be a list of all the dogs (iterating through the dogs list and adding them to the listSelectListItem )
            List <SelectListItem> listSelectListItem = new List <SelectListItem>();

            foreach (Dog dog in dogs)
            {
                //with each iteration we are setting the properties of this SelectListItem object
                //and adding each object to the list
                //Text is a property of the SelectListItem class (display text of the selected item)
                //Value is a property of SelectListItem class (value of the selected item- int needs to be converted to string)
                //Selected is a property of SelectListItem class (value that indicated whether this SelectListItem has been selected - boolean on the Dog class)
                SelectListItem selectListItem = new SelectListItem()
                {
                    Text     = dog.Name,
                    Value    = dog.Id.ToString(),
                    Selected = dog.isSelected
                };
                //with each iteration each item with these properties will be added to the list of dogs
                listSelectListItem.Add(selectListItem);
            }

            //instanstiate the viewmodel and set the properties of the viewmodel to the proper values; DogsList will be the listSelectListItem that was
            //formed with each addition of the dog to the list
            WalkFormViewModel vm = new WalkFormViewModel()
            {
                Walk     = new Walk(),
                Dogs     = dogs,
                Walkers  = walkers,
                DogsList = listSelectListItem
            };

            return(View(vm));
        }
Exemple #9
0
        // 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));
        }
        // GET: Walkers
        public IActionResult Index()

        {
            int           ownerId    = GetCurrentUserId();
            Owner         owner      = _ownerRepo.GetOwnerById(ownerId);
            List <Walker> AllWalkers = _walkerRepo.GetAllWalkers();

            if (owner == null)
            {
                return(View(AllWalkers));
            }
            List <Walker> walkers = AllWalkers.FindAll(walker => walker.NeighborhoodId == owner.NeighborhoodId);

            return(View(walkers));
        }
Exemple #11
0
        ///// 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));
            }
        }
Exemple #12
0
        //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));
            }
        }
Exemple #13
0
        // 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));
            }
        }
Exemple #14
0
        // 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));
        }
Exemple #15
0
        // 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));
            }
        }
        //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));
            }
        }
Exemple #17
0
        // 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));
        }
        public ActionResult Index()
        {
            //Chp 6 currentUserId attached to index, two lists generated based on logged in/out and list based on neighborhood match
            int   ownerId  = GetCurrentUserId();
            Owner theOwner = _ownerRepo.GetOwnerById(ownerId);

            List <Walker> walkers = _walkerRepo.GetAllWalkers();

            if (ownerId != 0)
            {
                return(View(walkers));
            }
            else
            {
                return(View(walkers));
            }
        }
Exemple #19
0
        // 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));
        }
Exemple #20
0
        // 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));
        }
Exemple #21
0
        // 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));
            }
        }
Exemple #22
0
        // 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));
        }
Exemple #23
0
        // 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));
        }
Exemple #24
0
        // GET: Walkers
        public ActionResult Index()
        {
            List <Walker> walkers = _walkerRepo.GetAllWalkers();

            return(View(walkers));
        }
        // GET: Walkers
        public ActionResult Index()
        {
            List <Walker> walkers = _walkerRepo.GetAllWalkers();

            return(View(walkers)); //this the controller passing data it got from the url to View
        }