public async Task <CommandResult> Handle(RemoveDietMealCommand request, CancellationToken cancellationToken) { Diet diet = await _dietRepository.GetByIdAsync(request.DietId); if (!FoundValidDiet(diet)) { return(FailureDueToDietNotFound()); } Meal meal = diet.FindMeal(request.DietMealId); diet.RemoveMeal(meal); if (!diet.IsValid) { return(FailureDueToEntityStateInconsistency(diet)); } await _mealRepository.RemoveAsync(meal); await _dietRepository.UpdateAsync(diet); return(await CommitAndPublishDefaultAsync()); }