Exemple #1
0
        public IActionResult UserGoals(UserGoalsView dto)
        {
            if (dto != null)
            {
                try
                {
                    var userGoals = new UserGoalsDto()
                    {
                        UserId = dto.UserId,
                        Calories = dto.Calories,
                        Carbohydrates = dto.Carbohydrates,
                        Fat = dto.Fat,
                        Proteins = dto.Proteins,
                        PercentageCarbs = dto.PercentageCarbs,
                        PercentageFat = dto.PercentageFat,
                        PercentageProtein = dto.PercentageProtein
                    };

                    userGoalsManamgenet.SetGoals(userGoals);
                }
                catch (Exception exc)
                {
                    ModelState.TryAddModelError("AdditionalValidation", exc.Message);
                }
            }

            return View(dto);
        }
Exemple #2
0
        public IActionResult UserGoals()
        {
            var goals = userGoalsManamgenet.GetCurrentUserGoals();

            if (goals.Calories == 0)
                goals.Calories = 1;

            var view = new UserGoalsView()
            {
                Calories = goals.Calories,
                Carbohydrates = goals.Carbohydrates,
                Fat = goals.Fat,
                Proteins = goals.Proteins,
                UserId = goals.UserId,
                PercentageCarbs = goals.PercentageCarbs,
                PercentageFat = goals.PercentageFat,
                PercentageProtein = goals.PercentageProtein
            };

            return View(view);
        }