Ejemplo n.º 1
0
        public ActionResult GetDisplayImage(int petId)
        {
            byte[] fileBytes = null;
            string fileType  = null;

            using (SystemContext context = new SystemContext())
            {
                var image = context.GetEntitySet <PetImage>().FirstOrDefault((img) => img.PetId == petId && img.IsDisplayPic == true);
                Debug.WriteLine("display image retrieved! filename: " + image.Name);

                if (image != null)
                {
                    fileBytes = image.Image;//the byte[]
                    fileType  = image.Type;
                }
                else
                {
                    Debug.WriteLine("Image is null.");
                }
            }

            return(File(fileBytes, fileType));
        }