Esempio n. 1
0
        public async Task <IActionResult> Get(Guid id, CancellationToken cancellationToken)
        {
            var group = await Client.GetByIdAsync(id, cancellationToken).ConfigureAwait(false);

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

            var first = await GetInitialExerciseGroup(cancellationToken).ConfigureAwait(false);

            var result = await _resultAdapter.AdaptAsync(group, first, cancellationToken).ConfigureAwait(false);

            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <IEnumerable <ExerciseGroupSummary> > AdaptAsync(IEnumerable <ExerciseGroup> groups, ExerciseGroup first, CancellationToken cancellationToken)
        {
            var results = await Task.WhenAll(groups.Select(async(group) =>
            {
                var result = await _resultAdapter.AdaptAsync(group, first, cancellationToken).ConfigureAwait(false);

                return(new ExerciseGroupSummary
                {
                    Id = result.Id,
                    Recorded = result.Recorded,
                    Weight = result.Weight,
                    CanDelete = result.CanDelete,
                    StartDate = first.Recorded,
                    ExerciseCount = result.Exercises.Count()
                });
            })).ConfigureAwait(false);

            return(results);
        }