Example #1
0
        public List <Driver> Parse(string[] commands)
        {
            foreach (var command in commands)
            {
                var person = Parse(command);
                if (person != null)
                {
                    switch (person)
                    {
                    case Driver driver:
                        _driverLogic.Save(driver);
                        break;

                    case Trip trip:
                        _tripLogic.Save(trip);
                        break;
                    }
                }
                else
                {
                    // theoretical log of error
                    Console.WriteLine($"Error loading command: <{command}>");
                }
            }

            // we've added all trips and drivers time to combine them
            return(CombineTripAndDriver());
        }
        public async Task <IActionResult> Create([Bind("DriverId,UserId,LicenceClassId,Experience")] Driver driver)
        {
            ViewBag.UserId = HttpContext.Session.GetInt32("UserId");

            driver.UserId = ViewBag.UserId;

            if (ModelState.IsValid)
            {
                _driverLogic.CreateDriver(driver);
                await _driverLogic.Save();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["LicenceClassId"] = new SelectList(_context.LicenceClass, "LicenceClassId", "LicenceClass1", driver.LicenceClassId);

            return(View(driver));
        }
        /// <summary>
        /// Register driver
        /// </summary>
        /// <param name="driver"></param>
        /// <returns></returns>
        public async Task <bool> RegisterDriver(Driver driver)
        {
            driver = await _driverLogic.Save(driver);

            // If save was successful
            if (driver != null)
            {
                switch (driver.Role)
                {
                case RolesEnum.Driver:
                    await _emailServiceApiApi.SendEmailAsync(driver.Email, "Tour of Milwaukee: Driver registration", $@"
                    <p> This is an automatically generated email. </p>
                    <p> ----------------------------------------- </p>
                    <p> Name: {driver.Fullname}</p>
                    <p> Role: {driver.Role}</p>
                    <p> Phone: {driver.Phone}</p>
                    <p> Capacity: {driver.Capacity}</p>
                    <p> Display Id: {driver.DisplayId}</p>
                    <p> Require Navigator: {(driver.RequireNavigator ? "Yes, navigator will be assigned to you" : $"No, my navigator is: {driver.Navigator}")}</p>
                    <br>
                    <p> {DateTime.Now.Year} Tour of Milwaukee</p>
                    <p> Date: August 31, {DateTime.Now.Year}</p>
                    <p> Time: 12:30 pm (Brief orientation only for drivers and navigators) </p>
                    <p> Address: 3202 N Maryland Ave, Milwaukee, WI 53211 </p>
                    <p> Location: Lubar Hall (Business Building, UWM) </p>
                    <br>
                    <p> Thank you for helping with the tour this year. Reply to this email will be sent automatically to the team.</p>
                    <p> For questions, comments and feedback, please contact Asher Imtiaz (414-499-5360) or Marie Wilke (414-852-5132).</p>
                    <br>
                    <p> Blessings, </p>
                ");

                    break;

                case RolesEnum.Navigator:
                    await _emailServiceApiApi.SendEmailAsync(driver.Email, "Tour of Milwaukee: Driver registration", $@"
                    <p> This is an automatically generated email. </p>
                    <p> ----------------------------------------- </p>
                    <p> Name: {driver.Fullname}</p>
                    <p> Role: {driver.Role}</p>
                    <p> Phone: {driver.Phone}</p>
                    <p> Display Id: {driver.DisplayId}</p>
                    <br>
                    <p> {DateTime.Now.Year} Tour of Milwaukee</p>
                    <p> Date: August 31, {DateTime.Now.Year}</p>
                    <p> Time: 12:30 pm (Brief orientation only for drivers and navigators) </p>
                    <p> Address: 3202 N Maryland Ave, Milwaukee, WI 53211 </p>
                    <p> Location: Lubar Hall (Business Building, UWM) </p>
                    <br>
                    <p> Thank you for helping with the tour this year. Reply to this email will be sent automatically to the team.</p>
                    <p> For questions, comments and feedback, please contact Asher Imtiaz (414-499-5360) or Marie Wilke (414-852-5132).</p>
                    <br>
                    <p> Blessings, </p>
                ");

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(true);
        }