예제 #1
0
        public async Task OnGetAsync(long?id)
        {
            if (id.HasValue)
            {
                Lawyer lawyer = await _lawyerService.GetLawyerByPrincipalAsync(User);

                LawyerSchedule schedule = lawyer.LawyerSchedules.FirstOrDefault(ls => ls.ID == id.Value);

                ScheduleId = id;

                TimeBegin = schedule.TimeBegin;
                TimeEnd   = schedule.TimeEnd;
                Date      = schedule.TimeBegin.Date;

                if (schedule.RecurringDays != RecurringDays.None)
                {
                    IsRecurring = true;
                    Sunday      = (schedule.RecurringDays & RecurringDays.Sunday) > 0;
                    Monday      = (schedule.RecurringDays & RecurringDays.Monday) > 0;
                    Tuesday     = (schedule.RecurringDays & RecurringDays.Tuesday) > 0;
                    Wednesday   = (schedule.RecurringDays & RecurringDays.Wednesday) > 0;
                    Thursday    = (schedule.RecurringDays & RecurringDays.Thursday) > 0;
                    Friday      = (schedule.RecurringDays & RecurringDays.Friday) > 0;
                    Saturday    = (schedule.RecurringDays & RecurringDays.Saturday) > 0;
                }
            }
            else
            {
                Date = DateTime.Today;
            }
        }
예제 #2
0
        /// <summary>
        /// Presents the lawyer with options to define the libraries they would be willing to meet veterans at
        /// </summary>
        public async Task OnGetAsync()
        {
            Lawyer lawyer = await _lawyerService.GetLawyerByPrincipalAsync(User);

            SelectedLibraryIds = (await _libraryService.GetAllLibrariesForLawyerAsync(lawyer.ApplicationUserId)).Select(l => l.ID);
            AllLibraries       = new MultiSelectList(_libraryService.GetAllLibraries(), "ID", "Name");
        }
        /// <summary>
        /// Displays a confirmation page to determine whether the user really wants to delete the specified schedule
        /// </summary>
        /// <param name="id">The primary key for the LawyerSchedule entity to delete</param>
        /// <returns>PageResult if the signed in user owns the schedule and the schedule exists. HTTP 404 otherwise</returns>
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            // Make sure the logged in user actually owns the specified schedule. If so, return PageResult
            if (id.HasValue)
            {
                Lawyer lawyer = await _lawyerService.GetLawyerByPrincipalAsync(User);

                LawyerSchedule = lawyer.LawyerSchedules.FirstOrDefault(ls => ls.ID == id.Value);

                if (LawyerSchedule != null)
                {
                    return(Page());
                }
            }

            // Either the schedule couldn't be found or it wasn't owned by the signed in user. Return HTTP 404
            return(NotFound());
        }
예제 #4
0
        /// <summary>
        /// Present the lawyer with their potential clients, library choices, schedules, and options to match
        /// with potential clients, change their libraries, and to modify their schedule.
        /// </summary>
        public async Task OnGetAsync()
        {
            Lawyer = await _lawyerService.GetLawyerByPrincipalAsync(User);

            Libraries = await _libraryService.GetAllLibrariesForLawyerAsync(Lawyer.ApplicationUserId);

            Schedules = await _lawyerService.GetSchedulesAsync(Lawyer.ApplicationUserId);

            PotentialClients = await _veteranService.GetPotentialClientsForLawyerAsync(Lawyer.ApplicationUserId);

            Matches = await _matchService.GetMatchesAsync();

            // TODO(taylorjoshuaw): Collect time zone from user rather than assuming Pacific time
            UserTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
        }
예제 #5
0
        /// <summary>
        /// The lawyer has confirmed they would like to initiate the matching process with the specified
        /// veteran. Add a new VeteranLawyerMatch row to the database to get the process started pending
        /// veteran approval.
        /// </summary>
        /// <param name="id">The primary key for the Veteran entity to match with</param>
        /// <returns>RedirectToPageResult to Index</returns>
        public async Task <IActionResult> OnPostAsync(string id)
        {
            Lawyer lawyer = await _lawyerService.GetLawyerByPrincipalAsync(User);

            if (await _lawyerService.MatchWithVeteranAsync(lawyer.ApplicationUserId, id, LibraryName))
            {
                // TODO(taylorjoshuaw): The next steps of matching would take place at this
                //                      point. This could be e- mail, a built-in agreement
                //                      system to coordinate location / time, etc.
                return(RedirectToPage("Index"));
            }

            // Something went wrong, send the user back to Index. This could use a message
            // to clarify the situation to the user, but TempData </3 Azure.
            _logger.LogError($"An error occurred while attempted to match Lawyer id: {lawyer.ApplicationUserId} with Veteran id: {id}");
            return(RedirectToPage("Index"));
        }