Exemplo n.º 1
0
    private string AppendMeal(Meals.NewMeal meal, List <Foods.NewFood> selectedFoods)
    {
        StringBuilder sb = new StringBuilder();

        sb.AppendLine(string.Format(@"<h4 style=""text-transform: uppercase"">{0}</h4>", meal.title));

        if (!string.IsNullOrWhiteSpace(meal.description))
        {
            sb.AppendLine(string.Format(@"
                                    <p style=""font-style: italic"">{0}</p>"
                                        , meal.description));
        }

        sb.AppendLine("<ul>");
        foreach (Foods.NewFood x in selectedFoods)
        {
            if (x.meal.code == meal.code)
            {
                sb.AppendLine(string.Format(@"
                                   <li><b>{0}</b>, {1} {2}, {3} g</li>"
                                            , x.food
                                            , x.quantity
                                            , x.unit
                                            , x.mass));
            }
        }
        sb.AppendLine("</ul>");
        return(sb.ToString());
    }
Exemplo n.º 2
0
    public string Init(Users.NewUser user)
    {
        NewMyMeals x = new NewMyMeals();

        x.id          = null;
        x.title       = null;
        x.description = null;
        x.userId      = user.userId;
        x.userGroupId = user.userGroupId;
        List <Meals.NewMeal> mm = new List <Meals.NewMeal>();
        List <Foods.MealsRecommendationEnergy> ee = new List <Foods.MealsRecommendationEnergy>();

        Meals.NewMeal m = new Meals.NewMeal();
        m.code        = "MM0";
        m.title       = "";
        m.description = "";
        m.isSelected  = true;
        m.isDisabled  = false;
        mm.Add(m);
        Foods.MealsRecommendationEnergy e = new Foods.MealsRecommendationEnergy();
        e.meal.code = m.code;
        e.meal.energyMinPercentage = 0;
        e.meal.energyMaxPercentage = 0;
        ee.Add(e);
        JsonFileMeals data = new JsonFileMeals();

        data.meals      = mm;
        data.energyPerc = ee;
        x.data          = data;
        return(JsonConvert.SerializeObject(x, Formatting.None));
    }
Exemplo n.º 3
0
    public string Template(Users.NewUser user, string lang)
    {
        NewMyMeals x = new NewMyMeals();

        x.id          = Guid.NewGuid().ToString();
        x.title       = t.Tran("example", lang).ToUpper();
        x.description = t.Tran("this is just an example, not a recommendation", lang);
        x.userId      = user.userId;
        x.userGroupId = user.userGroupId;
        List <Meals.NewMeal> mm = new List <Meals.NewMeal>();
        List <Foods.MealsRecommendationEnergy> ee = new List <Foods.MealsRecommendationEnergy>();
        string meal = t.Tran("meal", lang);

        Meals.NewMeal m = new Meals.NewMeal();
        m.code        = "MM0";
        m.title       = string.Format("{0} 1", meal);
        m.description = "07:00";
        m.isSelected  = true;
        m.isDisabled  = false;
        mm.Add(m);
        Foods.MealsRecommendationEnergy e = new Foods.MealsRecommendationEnergy();
        e.meal.code = m.code;
        e.meal.energyMinPercentage = 10;
        e.meal.energyMaxPercentage = 15;
        ee.Add(e);
        m             = new Meals.NewMeal();
        m.code        = "MM1";
        m.title       = string.Format("{0} 2", meal);
        m.description = "9:30";
        m.isSelected  = true;
        m.isDisabled  = false;
        mm.Add(m);
        e           = new Foods.MealsRecommendationEnergy();
        e.meal.code = m.code;
        e.meal.energyMinPercentage = 5;
        e.meal.energyMaxPercentage = 10;
        ee.Add(e);
        m             = new Meals.NewMeal();
        m.code        = "MM2";
        m.title       = string.Format("{0} 3", meal);
        m.description = "11:00";
        m.isSelected  = true;
        m.isDisabled  = false;
        mm.Add(m);
        e           = new Foods.MealsRecommendationEnergy();
        e.meal.code = m.code;
        e.meal.energyMinPercentage = 20;
        e.meal.energyMaxPercentage = 25;
        ee.Add(e);
        m             = new Meals.NewMeal();
        m.code        = "MM3";
        m.title       = string.Format("{0} 4", meal);
        m.description = "13:00";
        m.isSelected  = true;
        m.isDisabled  = false;
        mm.Add(m);
        e           = new Foods.MealsRecommendationEnergy();
        e.meal.code = m.code;
        e.meal.energyMinPercentage = 10;
        e.meal.energyMaxPercentage = 15;
        ee.Add(e);
        m             = new Meals.NewMeal();
        m.code        = "MM4";
        m.title       = string.Format("{0} 5", meal);
        m.description = "14:30";
        m.isSelected  = true;
        m.isDisabled  = false;
        mm.Add(m);
        e           = new Foods.MealsRecommendationEnergy();
        e.meal.code = m.code;
        e.meal.energyMinPercentage = 10;
        e.meal.energyMaxPercentage = 15;
        ee.Add(e);
        m             = new Meals.NewMeal();
        m.code        = "MM5";
        m.title       = string.Format("{0} 6", meal);
        m.description = "17:00";
        m.isSelected  = true;
        m.isDisabled  = false;
        mm.Add(m);
        e           = new Foods.MealsRecommendationEnergy();
        e.meal.code = m.code;
        e.meal.energyMinPercentage = 5;
        e.meal.energyMaxPercentage = 10;
        ee.Add(e);
        m             = new Meals.NewMeal();
        m.code        = "MM6";
        m.title       = string.Format("{0} 7", meal);
        m.description = "20:00";
        m.isSelected  = true;
        m.isDisabled  = false;
        mm.Add(m);
        e           = new Foods.MealsRecommendationEnergy();
        e.meal.code = m.code;
        e.meal.energyMinPercentage = 2;
        e.meal.energyMaxPercentage = 5;
        ee.Add(e);
        JsonFileMeals data = new JsonFileMeals();

        data.meals      = mm;
        data.energyPerc = ee;
        x.data          = data;
        return(JsonConvert.SerializeObject(x, Formatting.None));
    }