コード例 #1
0
        public ActionResult Index(DateTime?fromDate, DateTime?toDate)
        {
            var userId         = this.User.Identity.GetUserId();
            var foundTrainings = this.trainings
                                 .GetAllByUserWithPagingAndFiltering(userId, 0, PageSize, fromDate, toDate);
            var trainings = foundTrainings
                            .To <TrainingListItemViewModel>()
                            .ToList();

            var stats = new TrainingsStatsViewModel()
            {
                TotalAscent   = (foundTrainings.Count() > 0) ? foundTrainings.Sum(x => x.Track.Ascent) : 0,
                TotalLength   = (foundTrainings.Count() > 0) ? foundTrainings.Sum(x => x.Track.Length) : 0,
                TotalCalories = (foundTrainings.Count() > 0) ? foundTrainings.Sum(x => x.Calories) : 0,
            };

            var model = new TrainingsIndexViewModel()
            {
                Stats     = stats,
                Trainings = trainings
            };

            return(this.View(model));
        }
コード例 #2
0
        public ActionResult Index(DateTime? fromDate, DateTime? toDate)
        {
            var userId = this.User.Identity.GetUserId();
            var foundTrainings = this.trainings
                .GetAllByUserWithPagingAndFiltering(userId, 0, PageSize, fromDate, toDate);
            var trainings = foundTrainings
                .To<TrainingListItemViewModel>()
                .ToList();

            var stats = new TrainingsStatsViewModel()
            {
                TotalAscent = (foundTrainings.Count() > 0) ? foundTrainings.Sum(x => x.Track.Ascent) : 0,
                TotalLength = (foundTrainings.Count() > 0) ? foundTrainings.Sum(x => x.Track.Length) : 0,
                TotalCalories = (foundTrainings.Count() > 0) ? foundTrainings.Sum(x => x.Calories) : 0,
            };

            var model = new TrainingsIndexViewModel()
            {
                Stats = stats,
                Trainings = trainings
            };

            return this.View(model);
        }