Example #1
0
        public async Task <EmailFormViewModel> GetEmailForm()
        {
            var year = _globalConfigs.YearValue;

            return(new EmailFormViewModel
            {
                AdminCount = ApiConstants.AdminEmail.Length,
                StudentCount = (await _studentLogic.GetAll(year)).Count(),
                DriverCount = (await _driverLogic.GetAll(year)).Count(),
                HostCount = (await _hostLogic.GetAll(year)).Count(),
                UserCount = (await _userLogic.GetAll(year)).Count()
            });
        }
Example #2
0
        private List <Driver> CombineTripAndDriver()
        {
            var drivers = new List <Driver>();

            foreach (var driver in _driverLogic.GetAll())
            {
                driver.Trips = _tripLogic.GetByName(driver.Name).ToList();
                drivers.Add(driver);
            }

            return(drivers);
        }
Example #3
0
        /// <summary>
        /// Returns the status of mappings
        /// </summary>
        /// <returns></returns>
        public async Task <StudentDriverMappingViewModel> MappingStatus()
        {
            var students = (await _studentLogic.GetAll()).ToList();
            var drivers  = (await _driverLogic.GetAll()).Where(x => x.Role == RolesEnum.Driver).ToList();

            // TODO: add check to return only students that are present
            return(new StudentDriverMappingViewModel
            {
                AvailableStudents = students.Where(x => x.Driver == null),
                AvailableDrivers = drivers.ToDictionary(x => x, x =>
                {
                    // Count = to 1 + FamilySize
                    var cnt = (x.Students ?? new HashSet <Student>()).Select(st => 1 + st.FamilySize)
                              .DefaultIfEmpty(0)
                              .Sum();

                    return x.Capacity > cnt;
                }).ToList(),
                MappedDrivers = drivers.Where(x => x.Students != null && x.Students.Any()),
                MappedStudents = students.Where(x => x.Driver != null)
            });
        }
        /// <summary>
        /// Returns the status of mappings
        /// </summary>
        /// <returns></returns>
        public async Task <DriverHostMappingViewModel> MappingStatus()
        {
            var hosts   = (await _hostLogic.GetAll()).ToList();
            var drivers = (await _driverLogic.GetAll()).Where(x => x.Role == RolesEnum.Driver).ToList();

            // TODO: add check to return only students that are present
            return(new DriverHostMappingViewModel
            {
                AvailableHosts = hosts,
                AvailableDrivers = drivers.Where(x => x.Host == null),
                MappedDrivers = drivers.Where(x => x.Host != null),
                MappedHosts = hosts.Where(x => x.Drivers != null && x.Drivers.Any())
            });
        }
Example #5
0
        /// <summary>
        /// Handles sending email to drivers so they check-in
        /// </summary>
        /// <returns></returns>
        public async Task <bool> HandleDriverSendCheckIn()
        {
            (await _driverLogic.GetAll()).ForEach(x =>
            {
                var url = $"{ApiConstants.SiteUrl}/utility/EmailCheckIn/Driver/{x.GetHashCode()}";

                _emailServiceApi.SendEmailAsync(x.Email, $"Tour Driver Check-In and Host Info ({DateTime.UtcNow.Year})", $@"
                    <h4>Hello {x.Fullname},</h4>
                    <h4>Please use the following link to see details and to check-in</h4>
                    <p><a href=""{url}"">{url}</a></p>
                    <p>Most important thing to remember is your -Display ID-. Students are matched to this ID. The number next to your initials is unique.</p>
                    <p>The link has information about your host where you will go for dinner with students. </p>
                    <br>
                    <p>To save time when you arrive at UWM, just click on the button which says 'Check-In'. We will know that you are there and ready to drive students. Remember to pick up your Display ID when you arrive at the drivers area.</p>
                    <p>Reach out to us if there are issues.</p>
                    <p>Thank you</p>
                ");
            });

            return(true);
        }
 public async Task <IActionResult> Index()
 {
     return(View(await _driverLogic.GetAll()));
 }