Пример #1
0
 private bool canDeleteWeightRow()
 {
     try
     {
         if (StatisticCollection.Count() > 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка");
         return(false);
     }
 }
Пример #2
0
        public StatisticViewModel()
        {
            try
            {
                using (UnitOfWork unit = new UnitOfWork())
                {
                    LastSelected = default;

                    StatisticCollection = unit.UserParamRepository.Get(x => x.IdParams == DeserializedUser.deserializedUser.Id);
                    IEnumerable <Report> report             = unit.ReportRepository.Get(x => x.IdReport == DeserializedUser.deserializedUser.Id);
                    List <Report>        mostReportCategory = (List <Report>)unit.ReportRepository.Get(x => x.IdReport == DeserializedUser.deserializedUser.Id && DateTime.Today.Date.Date.Equals(x.ReportDate.Date));

                    if (mostReportCategory.Capacity != 0)
                    {
                        MostCategory = mostReportCategory.GroupBy(i => i.MostCategory).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key).First();
                    }
                    else
                    {
                        MostCategory = "---";
                    }

                    if (report.Count() != 0)
                    {
                        LastReportDate = report.Last().ReportDate.ToString();
                    }
                    else
                    {
                        LastReportDate = "---";
                    }

                    if (StatisticCollection.Count() != 0)
                    {
                        Height = StatisticCollection.Last().UserHeight;
                        Weight = StatisticCollection.Last().UserWeight;


                        ChartValues <decimal> weights = new ChartValues <decimal>(StatisticCollection.Select(x => x.UserWeight));
                        List <string>         labels  = new List <string>();

                        foreach (DateTime x in StatisticCollection.Select(x => x.ParamsDate))
                        {
                            labels.Add(x.ToString("d"));
                        }

                        Labels     = labels.ToArray();
                        YFormatter = value => value.ToString("0.00");

                        SeriesCollection = new SeriesCollection();

                        SeriesCollection.Add(new LineSeries
                        {
                            Title             = "Вес",
                            Values            = weights,
                            LineSmoothness    = 0,
                            PointGeometrySize = 15,
                            PointForeground   = Brushes.Coral,
                            Stroke            = Brushes.Coral,
                            Fill = Brushes.Transparent
                        });
                    }
                    else
                    {
                        Height = 0;
                        Weight = 0;
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Сообщение ошибки: " + exception.Message, "Произошла ошибка");
            }
        }