// GET: Speakers/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            // If no id specified, return not found
            if (id == null)
            {
                return(NotFound());
            }

            if (!await _speakerBL.SpeakerExists(id.Value))
            {
                return(NotFound());
            }

            // Find the specified speaker
            var speaker = await _speakerBL.GetSpeakerViewModel(id.Value);

            // If the speaker is not found, return not found
            if (speaker == null)
            {
                return(NotFound());
            }

            // Else return the view with the speaker information
            return(View(speaker));
        }
Example #2
0
        // GET: Speakers/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            // Get the user information
            var user = await _userManager.GetUserAsync(User);

            // If no id specified, return not found
            if (id == null)
            {
                return(NotFound());
            }

            if (!await _speakerBL.SpeakerExists(id.Value))
            {
                return(NotFound());
            }

            SpeakerViewModel speaker = null;

            // Find the specified speaker
            if (User.IsInRole("Admin"))
            {
                // Get all sessions
                speaker = await _speakerBL.GetSpeakerViewModel(id.Value);
            }
            else if (user != null && user.SpeakerId != null &&
                     user.SpeakerId == id.Value)
            {
                // Get all sessions
                speaker = await _speakerBL.GetSpeakerViewModel(id.Value);
            }
            else
            {
                // Only get approved sessions
                speaker = await _speakerBL.GetSpeakerViewModel(id.Value, true);
            }

            // If the speaker is not found, return not found
            if (speaker == null)
            {
                return(NotFound());
            }

            // Else return the view with the speaker information
            return(View(speaker));
        }
        public async Task <IActionResult> GetSpeakerImage(int speakerId)
        {
            if (!await _speakerBL.SpeakerExists(speakerId))
            {
                return(NotFound());
            }

            var speaker = await _context.Speakers.FindAsync(speakerId);

            if (speaker == null || speaker.Image == null || speaker.Image.Length == 0)
            {
                return(NotFound());
            }

            return(File(new MemoryStream(speaker.Image), "application/octet-stream"));
        }