コード例 #1
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));
        }