Exemple #1
0
        public ActionResult Home()
        {
            int          currentUserId = GetCurrentUserId();
            Walker       walker        = _walkerRepo.GetWalkerById(currentUserId);
            List <Walk>  walks         = _walkRepo.GetWalksByWalkerId(currentUserId);
            Neighborhood neighborhood  = _neighborhoodRepo.GetNeighborhoodById(walker.NeighborhoodId);
            List <Owner> clientOwners  = _ownerRepo.GetOwnersByEmployedWalkerId(walker.Id);
            List <Dog>   clientDogs    = _dogRepo.GetDogsByEmployedWalkerId(walker.Id);

            WalkerProfileViewModel vm = new WalkerProfileViewModel()
            {
                Walker        = walker,
                Walks         = walks,
                Neighborhood  = neighborhood,
                WalkSummaries = new List <WalkSummaryViewModel>(),
                clientOwners  = clientOwners,
                clientDogs    = clientDogs
            };

            foreach (Walk walk in vm.Walks)
            {
                vm.WalkSummaries.Add(new WalkSummaryViewModel()
                {
                    walk = walk
                });
            }

            if (vm.Walker == null)
            {
                return(NotFound());
            }

            return(View(vm));
        }
Exemple #2
0
        // GET: WalksController
        public ActionResult Index()
        {
            int ownerId = GetCurrentUserId();

            List <Walk> walks = _walkRepo.GetWalksByWalkerId(ownerId);

            return(View(walks));
        }
Exemple #3
0
        // GET: Walkers/Details/5
        public ActionResult Details(int id)
        {
            Walker walker = _walkerRepo.GetWalkerById(id);

            if (walker == null)
            {
                return(NotFound());
            }

            List <Walk>  walks     = _walkRepo.GetWalksByWalkerId(walker.Id);
            List <Owner> owners    = _ownerRepo.GetAllOwners();
            List <Dog>   ownerDogs = new List <Dog>();

            foreach (Owner owner in owners)
            {
                List <Dog> dogs = _dogRepo.GetDogsByOwnerId(owner.Id);
                ownerDogs.ForEach(dog => ownerDogs.Add(dog));
            }
            ;

            int      secs = walks.Sum(walk => walk.Duration);
            TimeSpan time = TimeSpan.FromSeconds(secs);

            WalkerProfileViewModel vm = new WalkerProfileViewModel
            {
                Walker    = walker,
                Walks     = walks,
                Owners    = owners,
                OwnerDogs = ownerDogs,
                WalkTime  = $"{time.Hours}hr {time.Minutes}min"
            };

            return(View(vm));
        }
        //Notice that this method accepts an id parameter. When the ASP.NET framework invokes this method for us, it will take whatever value is in the url and pass it to the Details method. For example, if the url is walkers/details/2, the framework will invoke the Details method and pass in the value 2. The code looks in the database for a walker with the id of 2. If it finds one, it will return it to the view. If it doesn't the user will be given a 404 Not Found page.
        // GET: WalkersConstrollers/Details/5
        public ActionResult Details(int id)
        {
            Walker      walker = _walkerRepo.GetWalkerById(id);
            List <Walk> walks  = _walkRepo.GetWalksByWalkerId(walker.Id);

            WalkerProfileViewModel vm = new WalkerProfileViewModel()
            {
                Walker = walker,
                Walks  = walks
            };

            return(View(vm));
        }
        // GET: Walkers/Details/5
        public ActionResult Details(int id)
        {
            Walker      walkers = _walkerRepo.GetWalkerById(id);
            List <Walk> walks   = _walkRepo.GetWalksByWalkerId(id);

            WalkerFormViewModel vm = new WalkerFormViewModel()
            {
                Walker = walkers,
                Walks  = walks
            };

            if (vm == null)
            {
                return(NotFound());
            }
            return(View(vm));
        }
Exemple #6
0
        // GET: Walkers/Details/5
        public ActionResult Details(int id)
        {
            Walker       walker       = _walkerRepo.GetWalkerById(id);
            Neighborhood neighborhood = _neighborhoodRepo.GetNeighborhoodByWalkerId(walker.Id);
            List <Walk>  walks        = _walkRepo.GetWalksByWalkerId(walker.Id);
            List <Dog>   dogs         = _dogRepo.GetDogsByOwnerId(walker.Id);


            WalkerProfileViewModel vm = new WalkerProfileViewModel()
            {
                Walker       = walker,
                Neighborhood = neighborhood,
                Walks        = walks,
                Dogs         = dogs
            };

            return(View(vm));
        }
Exemple #7
0
        // GET: WalkersController/Details/5
        public ActionResult Details(int id)
        {
            Walker      walker = _walkerRepo.GetWalkerById(id);
            List <Walk> walks  = _walkRepo.GetWalksByWalkerId(walker.Id);

            DetailViewModel vm = new DetailViewModel()
            {
                Walker = walker,
                Walks  = walks
            };

            return(View(vm));

            //if (walker == null)
            //{
            //    return NotFound();
            //}

            //return View(walker);
        }