Exemplo n.º 1
0
        public async Task <TaskCount> TaskOverview()
        {
            var tasks    = new List <Taskz>();
            var AllTasks = await _context.Tasks.ToListAsync();

            if (AllTasks?.Any() == true)
            {
                foreach (var task in AllTasks)
                {
                    tasks.Add(new Taskz()
                    {
                        TimeSheet = task.TimeSheet,
                        StartDate = task.StartDate,
                        EndDate   = task.EndDate
                    });
                }
            }
            int total     = tasks.Count();
            int ongoing   = 0;
            int timeout   = 0;
            int finalized = 0;
            int today     = 0;
            int pending   = 0;

            foreach (var task in tasks)
            {
                if (task.TimeSheet == true)
                {
                    finalized++;
                }
                if (task.EndDate < DateTime.Now)
                {
                    timeout++;
                }
                if (task.StartDate.Date == DateTime.Today || task.EndDate.Date == DateTime.Today)
                {
                    today++;
                }
                if (task.StartDate > DateTime.Now)
                {
                    pending++;
                }
                if (task.EndDate >= DateTime.Now && task.StartDate <= DateTime.Now)
                {
                    ongoing++;
                }
            }

            var count = new TaskCount();

            count.Total     = total;
            count.Today     = today;
            count.Ongoing   = ongoing;
            count.Pending   = pending;
            count.Finalized = finalized;
            count.TimeOut   = timeout;

            return(count);
        }
Exemplo n.º 2
0
        public async Task <TaskCount> TaskOverview2()
        {
            var AllTasks = await _context.Tasks.Where(task => task.StartDate.Date == DateTime.Today || task.EndDate.Date == DateTime.Today).ToListAsync();

            var count = new TaskCount();

            if (AllTasks?.Any() == true)
            {
                int total     = AllTasks.Count();
                int ongoing   = 0;
                int timeout   = 0;
                int finalized = 0;
                int pending   = 0;

                foreach (var task in AllTasks)
                {
                    if (task.TimeSheet == true)
                    {
                        finalized++;
                    }
                    if (task.EndDate < DateTime.Now)
                    {
                        timeout++;
                    }
                    if (task.StartDate > DateTime.Now)
                    {
                        pending++;
                    }
                    if (task.EndDate >= DateTime.Now && task.StartDate <= DateTime.Now)
                    {
                        ongoing++;
                    }
                }


                count.Total     = total;
                count.Ongoing   = ongoing;
                count.Pending   = pending;
                count.Finalized = finalized;
                count.TimeOut   = timeout;
            }
            return(count);
        }