コード例 #1
0
        public async Task <IActionResult> TrainingListForSelectedDate([FromBody] CurrentDisplayedDate currentDisplayedDate)
        {
            string userName = DebugAuth.getUserName(User);
            var    list     = await _trainingService.TrainingListForSelectedDate(currentDisplayedDate, userName);

            return(Ok(new
            {
                data = list,
                date = currentDisplayedDate.currentDate
            }));
        }
コード例 #2
0
        public async Task <List <KeyValuePair <DateTime, DayData> > > TrainingListForSelectedDate(CurrentDisplayedDate date, string userName)
        {
            Guid userID = await _accountDataAccess.GetUserIdAsync(userName);

            var periodOfTime = GetPeriodOfTimeForCurrentMonth(date.currentDate);

            var trainingList = await _trainingDataAccess.GetTreningListForMonth(periodOfTime, userID);

            var dayList = GetDateListByPeriodOfTime(periodOfTime);

            var output = dayList.ToDictionary(time => time.Date, time =>
                                              new DayData
            {
                Type         = time.Month == date.currentDate.Month ? 'c' : time.Month < date.currentDate.Month ? 'p' : 'n',
                TrainingList = trainingList
                               .Where(t => t.TrainingTime.Date == time.Date.Date)
                               .Select(t => new WorkoutDomain
                {
                    Id            = t.Id,
                    UserId        = t.UserId,
                    TrainingTime  = t.TrainingTime,
                    WorkoutDetail = JsonConvert.DeserializeObject <WorkoutDetail>(t.Detail),
                    Localizations = DeserializeLocalizations(t.Gps).ToList(),
                    Type          = (TrainingType)t.Type,
                }).ToList()
            }).ToList();

            return(output);
        }