예제 #1
0
        public async Task <CommandResult> Handle(UpdateDietCommand request, CancellationToken cancellationToken)
        {
            Diet diet = await _dietRepository.GetByIdAsync(request.DietId);

            if (!FoundValidDiet(diet))
            {
                return(FailureDueToDietNotFound());
            }

            diet.Update(
                request.Name,
                request.Description
                );

            await _dietRepository.UpdateAsync(diet);

            return(await CommitAndPublishDefaultAsync());
        }
예제 #2
0
        private async Task RecalculateDietTotalMacrosAsync(Guid dietId)
        {
            Diet diet = await _dietRepository.GetByIdAsync(dietId);

            diet.RecalculateDietTotalMacros();

            await _dietRepository.UpdateAsync(diet);

            await CommitAsync();
        }