public async Task <IActionResult> GetDailyMeals() { var meals = await _repoUser.GetDailyMealsAsync(); var mealsFiltered = meals.Where(dm => dm.CreatedBy == int.Parse(User.FindFirst(claim => claim.Type == ClaimTypes.NameIdentifier).Value)); return(Ok(_mapper.Map <List <DailyMealBasicDto> >(mealsFiltered))); }
public async Task AdjustDailyDemand(int userId) { var caloriesFromCurrentDM = await _repoDailyMeal.GetDailyMealsAsync(); var userDetails = await _repoUser.GetUserDetail(userId) ?? throw new ArgumentNullException(nameof(userId)); var adjustedDD = userDetails.DailyDemand - caloriesFromCurrentDM.ToList().Select(dm => dm.CaloriesPerPortion).Sum(); userDetails.DailyDemandToRealize = adjustedDD; await _repoUser.SaveAll(); }