Esempio n. 1
0
        private void LoadStories()
        {
            var            repo = new HistoryRepository();
            List <History> data = repo.AllAsync();

            if (data != null && data.Count() > 0)
            {
                AddFirstValue(ref data);

                var summaryWorking = from h in data
                                     where h.IsWorking == true
                                     group h by h.End.Date into g
                                     select new GroupValue {
                    Category = g.Key.Date, Value = g.Sum(x => x.Durations)
                };

                var summaryBreaks = from h in data
                                    where h.IsWorking == false
                                    group h by h.End.Date into g
                                    select new GroupValue {
                    Category = g.Key.Date, Value = g.Sum(x => x.Durations)
                };


                Workings.AddRange(summaryWorking);
                Breaks.AddRange(summaryBreaks);
            }
            else
            {
                var today = new List <GroupValue>()
                {
                    new GroupValue()
                    {
                        Category = DateTime.Now.Date, Value = 0
                    }
                };
                Workings.AddRange(today);
                Breaks.AddRange(today);
            }
        }