public ActionResult ListView()
        {
            ViewBag.Message = "Your contact page.";

            // calling the GetEntries method from the EntriesRepository class
            var entry = _entryRepository.GetEntries();

            // returning the ListView with entry as parameter
            return(View(entry));
        }
Esempio n. 2
0
        public ActionResult Index()
        {
            List <Entry> entries = _entriesRepository.GetEntries();

            // Calculate the total activity.
            double totalActivity = entries
                                   .Where(e => e.Exclude == false)
                                   .Sum(e => e.Duration);

            // Determine the number of days that have entries.
            int numberOfActiveDays = entries
                                     .Select(e => e.Date)
                                     .Distinct()
                                     .Count();

            ViewBag.TotalActivity        = totalActivity;
            ViewBag.AverageDailyActivity = (totalActivity / (double)numberOfActiveDays);

            return(View(entries));
        }
Esempio n. 3
0
        // GET: Entries
        public ActionResult Index()
        {
            List <Entry> entries   = _entriesRepository.GetEntries();
            double       total     = entries.Where(e => e.Exclude == false).Sum(e => e.Duration);
            double       totalDays = entries.Select(e => e.Date).Distinct().Count();
            double       average   = total / totalDays;

            ViewBag.Total   = total;
            ViewBag.Average = average;
            return(View(entries));
        }
        public ActionResult Index()
        {
            List <Entry> entries = _entriesRepository.GetEntries();

            // Calculate the total bugs.
            int totalBugs          = entries.Where(e => e.Exclude = false).Count();
            int numberOfActiveDays = entries.Select(e => e.Date).Distinct().Count();

            ViewBag.TotalBugs        = totalBugs;
            ViewBag.AverageDailyBugs = (totalBugs / (double)numberOfActiveDays);

            return(View(entries));
        }
        // Home page
        public ActionResult ViewDelete(int?id)
        {
            // delete the entry if an id value is provided
            if (id != null)
            {
                _entriesRepository.DeleteEntry(id.GetValueOrDefault(0));
            }

            // get the list entries for the index page list
            List <Entry> entries = _entriesRepository.GetEntries();

            // delete entry if id is provided
            return(View(entries));
        }
Esempio n. 6
0
        public ActionResult Index()
        {
            List <Entry> entries = _entriesRepository.GetEntries(); // here were making a call to the repository to get the list of available entries

            // Calculate the total activity.
            /* then we are using link to calculate the total activity by filtering out in the entries whose exclude properties are set to True and summing in the duration property values*/
            double totalActivity = entries
                                   .Where(e => e.Exclude == false)
                                   .Sum(e => e.Duration);

            // Determine the number of days that have entries.
            /* in order to calculate the average daily activity we're getting the count of the disctinct entry values, which will later */
            int numberOfActiveDays = entries
                                     .Select(e => e.Date)
                                     .Distinct()
                                     .Count();

            ViewBag.TotalActivity        = totalActivity;
            ViewBag.AverageDailyActivity = (totalActivity / (double)numberOfActiveDays);

            return(View(entries));
        }