Example #1
0
        public ActionResult Index()
        {
            var frequency = service.CalculateFrequencyRate(new DateTime(2017, 03, 06), new DateTime(2017, 03, 10));

            var occupancy = service.CalculateOccupancyRate(new DateTime(2017, 03, 06), new DateTime(2017, 03, 10));

            var utilisation = service.CalculateUtilisationRate(new DateTime(2017, 03, 06), new DateTime(2017, 03, 10));


            ViewBag.Message = "Frequency rate is:" + frequency.ToString("0.##\\%") +
                              " Occupancy rate is:" + occupancy.ToString("0.##\\%") +
                              " Utilisation rate is:" + utilisation.ToString("0.##\\%");
            return(View());
        }
Example #2
0
        /// <summary>
        /// Gets the week overview for a date
        /// </summary>
        /// <param name="date">The date that will be used to calculate the week starting date from</param>
        /// <returns>Dashbaord/WeekInformation</returns>
        public ActionResult WeekInformation(DateTime date)
        {
            //Finds the week start date
            date = FindStartDate(date);

            //Generates utilisation chart for the week
            var chart = GenerateWeekChart(date, "WeekChart");

            //Calculates the frequency, occupancy and utilisation rates for the company for the week
            var model = new WeekOverview
            {
                Chart           = chart,
                Frequency       = (service.CalculateFrequencyRate(date, date.AddDays(4)) * 100).ToString("0.##\\%"),
                Occupancy       = (service.CalculateOccupancyRate(date, date.AddDays(4)) * 100).ToString("0.##\\%"),
                Utilisation     = (service.CalculateUtilisationRate(date, date.AddDays(4)) * 100).ToString("0.##\\%"),
                DateInformation = new DateInformation
                {
                    StartDate = date,
                    EndDate   = date.AddDays(4),
                },
            };

            //Calculates the frequency, occupancy and utilisation rates for every resource for the week
            var resources = converter.ConvertResourceListFromWrapper(resourceService.GetResources());

            foreach (Resource resource in resources)
            {
                model.Resources.Add(new ResourceOverview
                {
                    Resource    = resource,
                    Utilisation = (service.CalculateResourceUtilisationRate(date, date.AddDays(4), resource.ResourceId) * 100).ToString("0.##\\%"),
                    Frequency   = (service.CalculateResourceFrequencyRate(date, date.AddDays(4), resource.ResourceId) * 100).ToString("0.##\\%"),
                    Occupancy   = (service.CalculateResourceOccupancyRate(date, date.AddDays(4), resource.ResourceId) * 100).ToString("0.##\\%"),
                });
            }
            return(View(model));
        }