// 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)); }
// 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)); }