Ejemplo n.º 1
0
        // GET: Sponsors/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            // If no id is specified, return not found
            if (id.HasValue == false)
            {
                return(NotFound());
            }

            // If the sponsor does not exist, return not found
            if (!await _sponsorBL.SponsorExists(id.Value))
            {
                return(NotFound());
            }

            // Find the specified sponsor
            var sponsorVM = await _sponsorBL.GetSponsorViewModel(id.Value);

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

            // Else return the view with the sponsor information
            return(View(sponsorVM));
        }
        public async Task <IActionResult> GetSponsorImage(int sponsorId)
        {
            if (!await _sponsorBL.SponsorExists(sponsorId))
            {
                return(NotFound());
            }

            var sponsor = await _context.Sponsors.FindAsync(sponsorId);

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

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