Пример #1
0
        public ActionResult GetImage(int photoId)
        {
            PhotoToDB photo = db.PhotosToDB.FirstOrDefault(p => p.PhotoId == photoId);

            if (photo != null)
            {
                return(File(photo.Image, photo.ImageMimeType));
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        public async Task <ActionResult> Create([Bind(Include = "Name")] PhotoToDB photo, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid && upload != null)
            {
                photo.ImageMimeType = upload.ContentType;
                photo.Image         = new byte[upload.ContentLength];
                upload.InputStream.Read(photo.Image, 0, upload.ContentLength);

                db.PhotosToDB.Add(photo);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(photo));
        }
Пример #3
0
        public ActionResult Create()
        {
            var photo = new PhotoToDB();

            return(View(photo));
        }