Esempio n. 1
0
        public IActionResult Index()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("Login", "Owners"));
            }
            ;

            int    userId = ControllerUtils.GetCurrentUserId(User);
            string role   = ControllerUtils.GetCurrentUserRole(User);

            if (role == "DogWalker")
            {
                //redirect to a walker page
            }
            if (role == "DogOwner")
            {
                return(RedirectToAction("Details", "Owners", new { id = userId }));
            }

            //THis lne should never execute
            return(RedirectToAction("Index", "Walkers"));
        }
Esempio n. 2
0
        // GET: OwnerController/Details/5
        public ActionResult Details(int id)
        {
            int currentUserId = ControllerUtils.GetCurrentUserId(User);

            if (currentUserId != id)
            {
                return(NotFound());
            }

            Owner         owner   = _ownerRepo.GetOwnerById(id);
            List <Dog>    dogs    = _dogRepo.GetDogsByOwnerId(owner.Id);
            List <Walker> walkers = _walkerRepo.GetWalkersInNeighborhood(owner.NeighborhoodId);
            List <Walk>   walks   = _walkRepo.GetWalksByOwnerId(id);

            ProfileViewModel vm = new ProfileViewModel()
            {
                Owner   = owner,
                Dogs    = dogs,
                Walkers = walkers,
                Walks   = walks
            };

            return(View(vm));
        }
Esempio n. 3
0
        // GET: OwnerController
        public ActionResult Index()
        {
            int currentUserId = ControllerUtils.GetCurrentUserId(User);

            return(RedirectToAction("Details", new { id = currentUserId }));
        }