예제 #1
0
        public async Task <IActionResult> Info(string volunteerId)
        {
            if (!User.Identity.IsAuthenticated)
            {
                throw new UnauthorizedAccessException();
            }

            GetAccessToken();
            VolunteerViewModel volunteerViewModel = new();

            try
            {
                _logger.LogInformation("Trying to get volunteer information...");
                var volunteerData = await _volunteerService.GetVolunteerAsync(volunteerId);

                foreach (var d in volunteerData)
                {
                    volunteerViewModel.Id        = d.Id;
                    volunteerViewModel.UpdatedAt = d.UpdatedAt;
                }
                _logger.LogInformation("Successfully requested volunteer info.");
                return(View(volunteerViewModel));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }

            return(View(volunteerViewModel));
        }