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()); }
private async Task RecalculateDietTotalMacrosAsync(Guid dietId) { Diet diet = await _dietRepository.GetByIdAsync(dietId); diet.RecalculateDietTotalMacros(); await _dietRepository.UpdateAsync(diet); await CommitAsync(); }