コード例 #1
0
ファイル: WalkersController.cs プロジェクト: bloges56/DogGo
        // GET: Walkers/Details/5
        public ActionResult Details(int id)
        {
            Walker       walker = _walkerRepo.GetWalkerById(id);
            List <Walks> walks  = _walkerRepo.GetWalksByWalkerId(id);

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

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

            return(View(vm));
        }
コード例 #2
0
        // GET: Walkers/Details/
        public ActionResult Details(int id)
        {
            Walker      walker = _walkerRepo.GetWalkerById(id);
            List <Walk> walks  = _walkerRepo.GetWalksByWalkerId(id);

            // Initiate variable to hold total seconds the walker walked
            int secondsWalked = 0;

            foreach (Walk walk in walks)
            {
                secondsWalked += walk.Duration;
            }
            walker.TotalWalkTime = DateTime.Today.Add(TimeSpan.FromSeconds(secondsWalked)).ToString("hh:mm");
            WalkerProfileViewModel vm = new WalkerProfileViewModel()
            {
                Walker = walker,
                Walks  = walks
            };

            return(View(vm));
        }