示例#1
0
        private void showProdInPlate_(SqlDateTime t)
        {
            var ShowProducts =
                from mpl in myplateRep.MyPlates().AsEnumerable()
                join r in platefoodrecordRepositoryRep.PlateFoodRecords().AsEnumerable() on mpl.Id equals r.PlateId
                join p in foodRep.Products().AsEnumerable() on r.FoodId equals p.Id
                where mpl.mealtime.Day == t.Value.Day && mpl.mealtime.Month == t.Value.Month
                select new
            {
                time          = mpl.mealtime,
                food          = p.FoodName,
                proteins      = p.Proteins * r.Weight / 100,
                fats          = p.Fat * r.Weight / 100,
                carbohydrates = p.Carbohydrates * r.Weight / 100,
                call          = p.CaloricValue * r.Weight / 100
            };

            foreach (var p in ShowProducts.AsEnumerable().OrderBy(x => x.time.Hour))//отсортировала время по возрастанию
            {
                items_.Add(new PlateItems()
                {
                    _time = p.time, _food = p.food, _proteins = p.proteins, _fats = p.fats, _carbohydrates = p.carbohydrates, _call = p.call
                });
            }

            dataGridCurrentPlate.ItemsSource = items_;
        }
        private void showStat_(SqlDateTime d, SqlDateTime t, int days)
        {
            List <PlateItems> items_    = new List <PlateItems>();
            List <PlateItems> user_stat = new List <PlateItems>();

            var ShowProducts =
                from mpl in myplateRep.MyPlates().AsEnumerable()
                join r in platefoodrecordRepositoryRep.PlateFoodRecords().AsEnumerable() on mpl.Id equals r.PlateId
                join p in foodRep.Products().AsEnumerable() on r.FoodId equals p.Id
                where mpl.mealtime.Date >= t.Value.Date && mpl.mealtime.Date <= d.Value.Date
                select new
            {
                time          = mpl.mealtime,
                food          = p.FoodName,
                proteins      = p.Proteins * r.Weight / 100,
                fats          = p.Fat * r.Weight / 100,
                carbohydrates = p.Carbohydrates * r.Weight / 100,
                call          = p.CaloricValue * r.Weight / 100
            };

            foreach (var p in ShowProducts.OrderBy(x => x.time.Hour))//отсортировала время по возрастанию
            {
                items_.Add(new PlateItems()
                {
                    _time = p.time, _food = p.food, _proteins = p.proteins, _fats = p.fats, _carbohydrates = p.carbohydrates, _call = p.call
                });
            }

            var most = (from i in items_
                        group i._food by i._food into grp
                        orderby grp.Count() descending
                        select new { grp.Key, Cnt = grp.Count() }).Where(r => r.Cnt > 1);

            foreach (var p in most)
            {
                user_stat.Add(new PlateItems()
                {
                    _count = p.Cnt, _food = p.Key
                });
            }
            dataGridStatistic.ItemsSource = user_stat;

            float avg = 0;

            if (days == 7)
            {
                avg = items_.Sum(x => x._call) / 7;
            }
            else
            {
                avg = items_.Sum(x => x._call) / 30;
            }

            labelAvgCal.Content = avg.ToString("0.00") + " ccal";
        }
        private void showProdInPlate_(SqlDateTime t)
        {
            float proteins      = 0;
            float fats          = 0;
            float carbohydrates = 0;
            float ccal          = 0;
            float totalWeight   = 0;

            var ShowProducts =
                from mpl in myplateRep.MyPlates().AsEnumerable()
                join r in platefoodrecordRepositoryRep.PlateFoodRecords().AsEnumerable() on mpl.Id equals r.PlateId
                join p in foodRep.Products().AsEnumerable() on r.FoodId equals p.Id
                where mpl.mealtime.Day == t.Value.Day && mpl.mealtime.Month == t.Value.Month
                select new
            {
                time          = mpl.mealtime,
                food          = p.FoodName,
                proteins      = p.Proteins * r.Weight / 100,
                fats          = p.Fat * r.Weight / 100,
                carbohydrates = p.Carbohydrates * r.Weight / 100,
                call          = p.CaloricValue * r.Weight / 100
            };

            foreach (var p in ShowProducts)
            {
                proteins      += p.proteins;
                fats          += p.fats;
                carbohydrates += p.carbohydrates;
                ccal          += p.call;
            }

            totalWeight = proteins + fats + carbohydrates;

            try
            {
                UserC.Value        = (int)(carbohydrates * 2 * 100 / totalWeight);
                UserProteins.Value = (int)(proteins * 2 * 100 / totalWeight);
                UserFats.Value     = (int)(fats * 2 * 100 / totalWeight);
                TBuserF.Text       = (UserFats.Value / 2).ToString();
                TBuserP.Text       = (UserProteins.Value / 2).ToString();
                TBuserC.Text       = (UserC.Value / 2).ToString();
            }
            catch (Exception)
            {
                return;
            }
        }
示例#4
0
        private void showProdInPlate_(SqlDateTime t)
        {
            List <DailyManuDetales> _items = new List <DailyManuDetales>();

            float proteins      = 0;
            float fats          = 0;
            float carbohydrates = 0;
            float ccal          = 0;

            List <PlateItems> items_ = new List <PlateItems>();

            var ShowProducts =
                from mpl in myplateRep.MyPlates().AsEnumerable()
                join r in platefoodrecordRepositoryRep.PlateFoodRecords().AsEnumerable() on mpl.Id equals r.PlateId
                join p in foodRep.Products().AsEnumerable() on r.FoodId equals p.Id
                where mpl.mealtime.Day == t.Value.Day && mpl.mealtime.Month == t.Value.Month
                select new
            {
                time          = mpl.mealtime,
                food          = p.FoodName,
                proteins      = p.Proteins * r.Weight / 100,
                fats          = p.Fat * r.Weight / 100,
                carbohydrates = p.Carbohydrates * r.Weight / 100,
                call          = p.CaloricValue * r.Weight / 100
            };

            foreach (var p in ShowProducts)
            {
                proteins      += p.proteins;
                fats          += p.fats;
                carbohydrates += p.carbohydrates;
                ccal          += p.call;
            }

            _items.Add(new DailyManuDetales {
                Title = "Белки", Completion = proteins, MinValue = 58, MaxValue = 87, tooltip = "Рекоммендуемая суточная норма 58..87г. В вашем меню " + proteins.ToString() + " г", Color = "Green"
            });
            _items.Add(new DailyManuDetales {
                Title = "Жиры", Completion = fats, MinValue = 60, MaxValue = 102, tooltip = "Рекоммендуемая суточная норма 60..102г. В вашем меню " + fats.ToString() + " г", Color = "Green"
            });
            _items.Add(new DailyManuDetales {
                Title = "Углеводы", Completion = carbohydrates, MinValue = 257, MaxValue = 586, tooltip = "Рекоммендуемая суточная норма 257..586г. В вашем меню " + carbohydrates.ToString() + " г", Color = "Green"
            });
            _items.Add(new DailyManuDetales {
                Title = "ССal", Completion = ccal, MinValue = 0, MaxValue = ((int)(user._Ccal) + 500), tooltip = "Рекоммендуемая суточная норма " + YourCcal.Text + "ccal. В вашем меню " + ccal.ToString() + " ccal", Color = "Green"
            });
            if (proteins >= 58 && proteins <= 87)
            {
                _items[0].tooltip += "\nПотребление белков в пределах нормы!";
            }
            else if (proteins > 87)
            {
                _items[0].Color    = "Red";
                _items[0].tooltip += "\nНеобходимо снизить потребление белков!";
            }
            else if (proteins < 58)
            {
                _items[0].tooltip += "\nНеобходимо повысить потребление белков!";
            }


            if (fats >= 60 && fats <= 102)
            {
                _items[1].tooltip += "\nПотребление жиров в пределах нормы!";
            }
            else if (fats > 102)
            {
                _items[1].Color    = "Red";
                _items[1].tooltip += "\nНеобходимо снизить потребление жиров!";
            }
            if (fats < 60)
            {
                _items[1].tooltip += "\nНеобходимо повысить потребление жиров!";
            }

            if (carbohydrates >= 257 && carbohydrates <= 585)
            {
                _items[2].tooltip += "\nПотребление углеводов в пределах нормы!";
            }
            else if (carbohydrates > 585)
            {
                _items[2].Color    = "Red";
                _items[2].tooltip += "\nНеобходимо снизить потребление углеводов!";
            }

            else if (carbohydrates < 257)
            {
                _items[2].tooltip += "\nНеобходимо повысить потребление углеводов!";
            }


            if (ccal > (user._Ccal))
            {
                _items[3].Color    = "Red";
                _items[3].tooltip += "\nВы рискуете попровиться!";
            }
            else
            {
                _items[3].tooltip += "\nВаш рацион не добавит вам лишних килограммов!";
            }

            DetalesOfDailyMenuList.ItemsSource = _items;
            DetalesOfDailyMenuList.Items.Refresh();
        }